Stackoverflow in self referencing class

Versions:

  • Eclipse 2020-06 (4.16)
  • SonarLint for Eclipse 5.3.0

Stacktrace:

java.lang.StackOverflowError
                at java.base/java.util.HashMap.hash(HashMap.java:339)
                at java.base/java.util.HashMap.containsKey(HashMap.java:591)
                at com.google.common.collect.AbstractMapBasedMultimap.containsKey(AbstractMapBasedMultimap.java:180)
                at com.google.common.collect.ArrayListMultimap.containsKey(ArrayListMultimap.java:61)
                at org.sonar.java.resolve.Scope.lookup(Scope.java:62)
                at org.sonar.java.resolve.Resolve.findMemberType(Resolve.java:214)
                at org.sonar.java.resolve.Resolve.findMemberType(Resolve.java:222)
                at org.sonar.java.resolve.Resolve.findMemberType(Resolve.java:234)
                [... last line repeats until end of log-message]

Eclipse shows a warning that requests eclipse to be restarted, but immediately after the restart (or every time the file is saved/build) the error is shown again. The error prevents eclipse from actually building the class so you don’t have access to the actual compiler error message.

Steps to reproduce

Create a class similar to this one:

package de.st_ddt.example;

public abstract class Test implements Test { // Implement itself

    @Override // <-- This one is important
    public abstract void testMethod();

}

I stumbled across this error after a broken refactor. The broken refactorcaused tons of errors in the code but due to the Stackoverflow during the build the other errors won’t get cleared up and I ended up searching the needle in the hay port. I had to remove Sonar to find the actual compile error.

Potential workaround:

  • Fix the broken class/self-reference (if you are able to find them)

Hey @ST-DDT ,

I tried on my side with SonarLint for Eclipse 5.3, and I can not reproduce the issue.
Are you using SonarLint in connected mode with a given SonarQube instance?

SonarLint for Eclipse 5.3 is supposed to embed a version of the Java Analyzer (6.6) which does not have these org.sonar.java.resolve... classes anymore.

I only see what is annoying you being possible if a connected SonarQube instance is using an old version of the Java Analyzer (prior to 6.0), which means that this old analyzer would be used for analysis of your project locally.

  • If it’s the case, I would recommend upgrading the Java Analyzer in your SonarQube instance with a more recent version, and then update your binding on your local machine.
  • If it’s not the case, then I don’t really understand what Java Analyzer plugin you might have

Cheers,
Michael

1 Like

The issue seems to be caused by an old analyzer version.
Thanks for pointing this out.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.