1

我通过将项目绑定到我们的 SonarQube(安装了 SonarJava 5.3(内部版本 13828))服务器,将 SonarLint 4.1.1.3345 与 IntelliJ Community 2019.2 版本一起使用。但是,我从 SonarLint 日志中收到以下堆栈跟踪错误:

Java Main Files AST scan
60 source files to be analyzed
Unable to create symbol table for : C:\Users\username\SomeFile.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:204)
    at org.sonar.java.resolve.Symbols.<init>(Symbols.java:176)
    at org.sonar.java.resolve.SemanticModel.createFor(SemanticModel.java:59)
    at org.sonar.java.model.VisitorsBridge.visitFile(VisitorsBridge.java:110)
    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:74)
    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)

“不支持的类文件主要版本 55”告诉我,用于代码分析的类文件 Sonar 用于 java 11 版本,而我的类是用 java 7 编译的(我采用相同的类并用 javap 运行它显示主要版本 51),我什至没有在我的系统上安装 java 11。

因为它适用于我的队友。唯一的区别是他们安装了较低版本的 IntelliJ。所以我下载了 IntelliJ 2019.1.4 并开始工作。

有人可以解释为什么它不适用于更高版本的 IntelliJ 以及为什么会发生上述错误?提前致谢!

4

1 回答 1

1

这是 IDE/sonarlint/plugin 中类加载器的已知限制:

https://community.sonarsource.com/t/sonarlint-analysis-fails-on-intellij-2019-2-with-java-11-runtime/12905/3

https://jira.sonarsource.com/browse/SONARJAVA-3056

SonarLint 示例

在 SonarLint IntelliJ 运行环境中,这或多或少是类路径层次结构:

JDK -> IntelliJ 类 -> SonarLint (+deps) [child-first] -> Java plugin (+packaged deps) [child-first] -> Squid [parent-first]。所以假设我们分析一个使用类 X 的类。如果 IntelliJ 的类加载器碰巧也使用类 X(相同的完全限定名称),则将使用它而不是分析类路径中提供的 X,即使它们是不同的副本类的(例如不同的版本)。

于 2019-09-05T21:36:19.570 回答