Eclipse 2021-03 SonarLint Error

SonarQube: Version 7.4 (build 18908)
SonarLint: 5.8.1
Client Machine: JDK 1.8.0_202
Eclipse: 2021-03R

The SonarLint will automatically validate the file I’m editing during on-save, but it failed with errors and unable to highlights any sonar violation.

1 source files to be analyzed
Unable to create symbol table for : D:\project\src\main\java\com\test\TestClass.java
java.lang.IllegalArgumentException: Unsupported class file major version 59
	at org.objectweb.asm.ClassReader.<init>(ClassReader.java:176)
	at org.objectweb.asm.ClassReader.<init>(ClassReader.java:158)
	at org.objectweb.asm.ClassReader.<init>(ClassReader.java:146)
	at org.sonar.java.resolve.BytecodeCompleter.loadClass(BytecodeCompleter.java:244)
	at org.sonar.java.resolve.Symbols.<init>(Symbols.java:176)
	at org.sonar.java.resolve.SemanticModel.createFor(SemanticModel.java:60)
	at org.sonar.java.model.VisitorsBridge.visitFile(VisitorsBridge.java:109)
	at org.sonar.java.ast.JavaAstScanner.simpleScan(JavaAstScanner.java:96)
	at org.sonar.java.ast.JavaAstScanner.scan(JavaAstScanner.java:68)
	at org.sonar.java.JavaSquid.scanSources(JavaSquid.java:116)
	at org.sonar.java.JavaSquid.scan(JavaSquid.java:110)
	at org.sonar.plugins.java.JavaSquidSensor.execute(JavaSquidSensor.java:93)
	at org.sonarsource.sonarlint.core.analyzer.sensor.SensorsExecutor.executeSensor(SensorsExecutor.java:80)
	at org.sonarsource.sonarlint.core.analyzer.sensor.SensorsExecutor.execute(SensorsExecutor.java:71)
	at org.sonarsource.sonarlint.core.container.analysis.AnalysisContainer.doAfterStart(AnalysisContainer.java:134)
	at org.sonarsource.sonarlint.core.container.ComponentContainer.startComponents(ComponentContainer.java:126)
	at org.sonarsource.sonarlint.core.container.ComponentContainer.execute(ComponentContainer.java:111)
	at org.sonarsource.sonarlint.core.container.storage.StorageAnalyzer.analyze(StorageAnalyzer.java:75)
	at org.sonarsource.sonarlint.core.container.storage.StorageContainerHandler.analyze(StorageContainerHandler.java:84)
	at org.sonarsource.sonarlint.core.ConnectedSonarLintEngineImpl.lambda$analyze$0(ConnectedSonarLintEngineImpl.java:152)
	at org.sonarsource.sonarlint.core.ConnectedSonarLintEngineImpl.withReadLock(ConnectedSonarLintEngineImpl.java:349)
	at org.sonarsource.sonarlint.core.ConnectedSonarLintEngineImpl.withReadLock(ConnectedSonarLintEngineImpl.java:339)
	at org.sonarsource.sonarlint.core.ConnectedSonarLintEngineImpl.analyze(ConnectedSonarLintEngineImpl.java:149)
	at org.sonarlint.eclipse.core.internal.engine.connected.ConnectedEngineFacade.runAnalysis(ConnectedEngineFacade.java:309)
	at org.sonarlint.eclipse.core.internal.jobs.AnalyzeConnectedProjectJob.runAnalysis(AnalyzeConnectedProjectJob.java:72)
	at org.sonarlint.eclipse.core.internal.jobs.AnalyzeConnectedProjectJob.runAnalysis(AnalyzeConnectedProjectJob.java:1)
	at org.sonarlint.eclipse.core.internal.jobs.AbstractAnalyzeProjectJob.run(AbstractAnalyzeProjectJob.java:396)
	at org.sonarlint.eclipse.core.internal.jobs.AbstractAnalyzeProjectJob.runAnalysisAndUpdateMarkers(AbstractAnalyzeProjectJob.java:199)
	at org.sonarlint.eclipse.core.internal.jobs.AbstractAnalyzeProjectJob.doRun(AbstractAnalyzeProjectJob.java:161)
	at org.sonarlint.eclipse.core.internal.jobs.AbstractSonarProjectJob.run(AbstractSonarProjectJob.java:45)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)

Hi @Samuel_W

This means that your project in Eclipse is compiled with a target JDK 15.

Support of analysis of JDK 15 projects has been added in our Java analyzer in January and this is part of SonarQube 8.7.

I see you are using connected mode, so you have to update your SonarQube server (in connected mode, SonarLint use the same analyzer as the server).

Or you can unbind your project from SonarQube, to use the SonarLint embedded analyzer.

Hi @Julien_HENRY

Yes I am connected to the SonarQube server.
I’ve had the “Java Compiler Compliance Level” set to JDK 1.8 in my case because the project has to be compiled with JDK 1.8…but the SonarLint is still unable to lint the code.

Additionally, I do have my Java > Installed JREs set to JDK 1.8 of my local machine.

Any idea for this?

In addition, I did tried the same project using Eclipse 2020-06R with SonarLint 5.8.1 and connected to SonarQube server.
It is able to successfully lint the code with squiggly line highlighted on my code and reports in the “Markers” tab

I don’t think the Eclipse version should have an impact in itself (except if there is a bug in JDT). What could have an impact (and so you can compare on you two sides) are:

  • the version of the JVM used to run Eclipse itself: you can check that in Help → About Eclipse Platform → Installation Details → Configuration → eclipse.vm=xx
  • the version of the JRE used to compile your project (can be seen in project settings):
  • as you already checked, the compiler target version:

You could also clear/rebuild the entire project, just to be sure a .class file previously compiled with JDK 15 is not hanging around.

I’ve just found out the issue is using OpenJDK 11 that comes with Eclipse will throw this error, I’ve gone ahead and change it to Oracle JDK 11 in the eclipse.ini file, from

-vm
plugins/org.eclipse.justj.openjdk.hotspot.jre.full.win32.x86_64_15.0.2.v20210201-0955/jre/bin

to

-vm
C:\Program Files\Java\jdk-11.0.10\bin

Thanks a lot for the help btw, @Julien_HENRY

1 Like

To me it seems to be a JDK 15, and that would explain the behavior.

Anyway great to see you managed to fix your issue.

My bad, I kept mentioning JDK 11 and mistakenly thought of it as OpenJDK 11.

So does this mean SonarLint only works with Oracle JDK and it won’t work when used with OpenJDK?

Hey Sam,

As @Julien_HENRY mentioned it doesn’t seem to be a problem of OpenJDK vs. Oracle JDK, but thaht this JDK was Java 15 (rather than 11)

Hi @Colin,

You’re right, I’ve just tried using OpenJDK 11 and it works fine. So the issue seems to be with Java 15 instead.

May I confirm this is a known issue with java 15?

Thanks

Back to Julien’s point earlier :slight_smile:

Java 15 is supported nowadays, but not with SonarQube v7.4 (the version you’re using, and where SonarLint grabs the analyser from)

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