SonarLint Analysis fails on IntelliJ 2019.2 with Java 11 runtime

After upgrading to IntelliJ 2019.2 the SonarLint analysis in the IDE fails.
When using the IntelliJ version with a bundled Java 11 (“JBR11”) runtime (since 2019.2 the default version) on Mac OS X the analysis fails, while using the version with the Java 8 runtime works.

see https://www.jetbrains.com/idea/download/other.html
Default version: 2019.2 for Mac OS X
Java 8 version: 2019.2 for macOS with bundled JBR 8 (dmg)

SonarLint version: 4.1.0.3312
SonarQube version (connected mode): Community Edition Version 7.2.1 (build 14109)

An excerpt from the log:

Java Main Files AST scan
1 source files to be analyzed
Unable to create symbol table for : /Users/ralf/yes/platform/platform-rp-service/src/main/java/com/yes/platform/rp/access/AccessInterceptor.java
java.lang.IllegalArgumentException: Unsupported class file major version 55
	at org.objectweb.asm.ClassReader.<init>(ClassReader.java:166)
	at org.objectweb.asm.ClassReader.<init>(ClassReader.java:148)
	at org.objectweb.asm.ClassReader.<init>(ClassReader.java:136)
	at org.sonar.java.resolve.BytecodeCompleter.loadClass(BytecodeCompleter.java:242)
	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:81)
	at org.sonarsource.sonarlint.core.analyzer.sensor.SensorsExecutor.execute(SensorsExecutor.java:72)
	at org.sonarsource.sonarlint.core.container.analysis.AnalysisContainer.doAfterStart(AnalysisContainer.java:132)
	at org.sonarsource.sonarlint.core.container.ComponentContainer.startComponents(ComponentContainer.java:125)
	at org.sonarsource.sonarlint.core.container.ComponentContainer.execute(ComponentContainer.java:110)
	at org.sonarsource.sonarlint.core.container.storage.StorageAnalyzer.analyze(StorageAnalyzer.java:75)
	at org.sonarsource.sonarlint.core.container.storage.StorageContainerHandler.analyze(StorageContainerHandler.java:82)
	at org.sonarsource.sonarlint.core.ConnectedSonarLintEngineImpl.lambda$analyze$0(ConnectedSonarLintEngineImpl.java:152)
	at org.sonarsource.sonarlint.core.ConnectedSonarLintEngineImpl.withReadLock(ConnectedSonarLintEngineImpl.java:344)
	at org.sonarsource.sonarlint.core.ConnectedSonarLintEngineImpl.withReadLock(ConnectedSonarLintEngineImpl.java:334)
	at org.sonarsource.sonarlint.core.ConnectedSonarLintEngineImpl.analyze(ConnectedSonarLintEngineImpl.java:149)
	at org.sonarlint.intellij.core.ConnectedSonarLintFacade.analyze(ConnectedSonarLintFacade.java:73)
	at org.sonarlint.intellij.core.SonarLintFacade.startAnalysis(SonarLintFacade.java:63)
	at org.sonarlint.intellij.analysis.SonarLintAnalyzer.analyzeModule(SonarLintAnalyzer.java:97)
	at org.sonarlint.intellij.analysis.SonarLintTask.analyze(SonarLintTask.java:176)
	at org.sonarlint.intellij.analysis.SonarLintTask.run(SonarLintTask.java:100)
	at org.sonarlint.intellij.analysis.SonarLintUserTask.run(SonarLintUserTask.java:39)
	at org.sonarlint.intellij.analysis.SonarLintJobManager.lambda$runTask$1(SonarLintJobManager.java:120)
	at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$2(CoreProgressManager.java:169)
	at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:591)
	at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:537)
	at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:59)
	at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:156)
	at org.sonarlint.intellij.analysis.SonarLintJobManager.lambda$runTask$2(SonarLintJobManager.java:120)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:834)

1/1 source files have been analyzed
Java Main Files AST scan (done) | time=8ms
Java Test Files AST scan
0 source files to be analyzed
0/0 source files have been analyzed
Java Test Files AST scan (done) | time=1ms

One more information: The project in IntelliJ is configured to be built with Java 8 and uses a Java 8 runtime. (Project SDK & project language level)

Here is the error log and the plugins configuration:
error.txt (65.4 KB) plugins.txt (5.3 KB)

Hello @Ralf_Wagner, thank you for you feedback.

As far as I understand, the plugin used by SonarLint to analyze Java code fails to load the bytecode for one of your classes, due to it being compiled for Java 11 (major version 55). This looks strange to me since you mention that the project is configured with Java 8 language level and target. There might be a Java-11-built .class file hiding somewhere on your class path.

I notice in plugins.txt that the Java plugin served by your SonarQube instance has version 5.6 (build 15032), whereas the first version known to support Java 11 is 5.8 (build 15699), and the latest released version is 5.14 (build 18788).

My advice here is to upgrade your SonarQube server - FYI SonarQube 7.9.1 LTS has just been released - or at the very least update your server’s plugins. And as mentioned above, you might also want to double check that the project’s class path (including build output directory) is clean.

1 Like

@JBL_SonarSource Thanks for your quick reply.

I’ll check the class path again, but I already did so (and a colleague has the same problem).
We’re currently still using Java 8 for development purposes, so there should be no Java 11 compiler or runtime yet involved. Using the IntelliJ version that has Java 11 included seemed to be ok, as it is only used by IntelliJ internally.

Concerning the plugins: Our Sonar server does not offer the update any newer ones (I recently updated the plugins and checked again today), especially not the update of the plugin version supporting Java 11. I suppose this is due to the fact that the Sonar server version we’re currently using does not support newer plugins, or do I miss something here?

We’d definitely like to upgrade to the current version, but as this requires migrating the database from MySQL to most probably Postgress, this will take some time.

Thanks for your help and Sonar as a great tool.

This is a well known limitation of our Java analyzer. It is using the IDE runtime JRE to resolve JDK classes, while in a perfect world it should be using the JRE configured to compile the project.
See: https://jira.sonarsource.com/browse/SONARJAVA-3056

For now your only option is to upgrade SonarJava to a more recent version, and it might indeed require to also upgrade your server. Or stop using connected mode…