声纳Qube错误:"Unable to create symbol table for <Class>"



考虑以下类:

public class SqAnalysisTest {
public void method () {
    Collection<Reader> readers = new ArrayList<> ();
    readers.add (SqAnalysisTest::readString);
}
@FunctionalInterface
public static interface Reader {
    Object read (ByteBuffer buffer);
}
public static String readString (ByteBuffer buffer) {
    /* read string from buffer and return */
    return "a string"; 
}
}

这个编译得很好,但是当用SonarQube分析时,我得到了一个Unable to create symbol table for : <Class>错误(下面是完整的堆栈跟踪)。

我使用的是SonarQube 5.6.3,这发生在命令行(SonarQube Scanner 2.7)以及在Eclipse (SonarLint 2.2.1)。

PS:作为参考,这是我得到的完整堆栈跟踪:
    Unable to create symbol table for : C:WorkspacesE2prtrunk-completee2pr-servermaintoolssrccomiconscptoolsSqAnalysisTest.java
java.lang.ClassCastException: org.sonar.java.resolve.ClassJavaType cannot be cast to org.sonar.java.resolve.ParametrizedTypeJavaType
    at org.sonar.java.resolve.TypeAndReferenceSolver.refineType(TypeAndReferenceSolver.java:558) ~[java-frontend-4.2.jar:na]
    at org.sonar.java.resolve.TypeAndReferenceSolver.visitMethodReference(TypeAndReferenceSolver.java:946) ~[java-frontend-4.2.jar:na]
    at org.sonar.java.model.expression.MethodReferenceTreeImpl.accept(MethodReferenceTreeImpl.java:62) ~[java-frontend-4.2.jar:na]
    at org.sonar.java.resolve.TypeAndReferenceSolver.setInferedType(TypeAndReferenceSolver.java:299) ~[java-frontend-4.2.jar:na]
    at org.sonar.java.resolve.TypeAndReferenceSolver.inferArgumentTypes(TypeAndReferenceSolver.java:775) ~[java-frontend-4.2.jar:na]
    at org.sonar.java.resolve.TypeAndReferenceSolver.visitMethodInvocation(TypeAndReferenceSolver.java:245) ~[java-frontend-4.2.jar:na]
    at org.sonar.java.model.expression.MethodInvocationTreeImpl.accept(MethodInvocationTreeImpl.java:96) ~[java-frontend-4.2.jar:na]
    at org.sonar.plugins.java.api.tree.BaseTreeVisitor.scan(BaseTreeVisitor.java:43) ~[java-frontend-4.2.jar:na]
    at org.sonar.plugins.java.api.tree.BaseTreeVisitor.visitExpressionStatement(BaseTreeVisitor.java:101) ~[java-frontend-4.2.jar:na]
    at org.sonar.java.resolve.TypeAndReferenceSolver.visitExpressionStatement(TypeAndReferenceSolver.java:745) ~[java-frontend-4.2.jar:na]
    at org.sonar.java.model.statement.ExpressionStatementTreeImpl.accept(ExpressionStatementTreeImpl.java:65) ~[java-frontend-4.2.jar:na]
    at org.sonar.plugins.java.api.tree.BaseTreeVisitor.scan(BaseTreeVisitor.java:43) ~[java-frontend-4.2.jar:na]
    at org.sonar.plugins.java.api.tree.BaseTreeVisitor.scan(BaseTreeVisitor.java:37) ~[java-frontend-4.2.jar:na]
    at org.sonar.plugins.java.api.tree.BaseTreeVisitor.visitBlock(BaseTreeVisitor.java:85) ~[java-frontend-4.2.jar:na]
    at org.sonar.java.model.statement.BlockTreeImpl.accept(BlockTreeImpl.java:77) ~[java-frontend-4.2.jar:na]
    at org.sonar.plugins.java.api.tree.BaseTreeVisitor.scan(BaseTreeVisitor.java:43) ~[java-frontend-4.2.jar:na]
    at org.sonar.java.resolve.TypeAndReferenceSolver.visitMethod(TypeAndReferenceSolver.java:131) ~[java-frontend-4.2.jar:na]
    at org.sonar.java.model.declaration.MethodTreeImpl.accept(MethodTreeImpl.java:218) ~[java-frontend-4.2.jar:na]
    at org.sonar.plugins.java.api.tree.BaseTreeVisitor.scan(BaseTreeVisitor.java:43) ~[java-frontend-4.2.jar:na]
    at org.sonar.plugins.java.api.tree.BaseTreeVisitor.scan(BaseTreeVisitor.java:37) ~[java-frontend-4.2.jar:na]
    at org.sonar.java.resolve.TypeAndReferenceSolver.visitClass(TypeAndReferenceSolver.java:140) ~[java-frontend-4.2.jar:na]
    at org.sonar.java.model.declaration.ClassTreeImpl.accept(ClassTreeImpl.java:198) ~[java-frontend-4.2.jar:na]
    at org.sonar.plugins.java.api.tree.BaseTreeVisitor.scan(BaseTreeVisitor.java:43) ~[java-frontend-4.2.jar:na]
    at org.sonar.plugins.java.api.tree.BaseTreeVisitor.scan(BaseTreeVisitor.java:37) ~[java-frontend-4.2.jar:na]
    at org.sonar.plugins.java.api.tree.BaseTreeVisitor.visitCompilationUnit(BaseTreeVisitor.java:55) ~[java-frontend-4.2.jar:na]
    at org.sonar.java.resolve.SemanticModel.createFor(SemanticModel.java:62) ~[java-frontend-4.2.jar:na]
    at org.sonar.java.model.VisitorsBridge.visitFile(VisitorsBridge.java:107) ~[java-frontend-4.2.jar:na]
    at org.sonar.java.ast.JavaAstScanner.simpleScan(JavaAstScanner.java:84) [java-frontend-4.2.jar:na]
    at org.sonar.java.ast.JavaAstScanner.scan(JavaAstScanner.java:67) [java-frontend-4.2.jar:na]
    at org.sonar.java.JavaSquid.scanTests(JavaSquid.java:125) [java-frontend-4.2.jar:na]
    at org.sonar.java.JavaSquid.scan(JavaSquid.java:114) [java-frontend-4.2.jar:na]
    at org.sonar.plugins.java.JavaSquidSensor.execute(JavaSquidSensor.java:87) [sonar-java-plugin-4.2.jar:na]
    at org.sonarsource.sonarlint.core.analyzer.sensor.SensorWrapper.analyse(SensorWrapper.java:52) [org.sonarsource.sonarlint.core.sonarlint-core_2.4.1.jar:na]
    at org.sonarsource.sonarlint.core.analyzer.sensor.SensorsExecutor.executeSensor(SensorsExecutor.java:73) [org.sonarsource.sonarlint.core.sonarlint-core_2.4.1.jar:na]
    at org.sonarsource.sonarlint.core.analyzer.sensor.SensorsExecutor.execute(SensorsExecutor.java:63) [org.sonarsource.sonarlint.core.sonarlint-core_2.4.1.jar:na]
    at org.sonarsource.sonarlint.core.analyzer.sensor.PhaseExecutor.execute(PhaseExecutor.java:44) [org.sonarsource.sonarlint.core.sonarlint-core_2.4.1.jar:na]
    at org.sonarsource.sonarlint.core.container.analysis.AnalysisContainer.doAfterStart(AnalysisContainer.java:143) [org.sonarsource.sonarlint.core.sonarlint-core_2.4.1.jar:na]
    at org.sonarsource.sonarlint.core.container.ComponentContainer.startComponents(ComponentContainer.java:125) [org.sonarsource.sonarlint.core.sonarlint-core_2.4.1.jar:na]
    at org.sonarsource.sonarlint.core.container.ComponentContainer.execute(ComponentContainer.java:110) [org.sonarsource.sonarlint.core.sonarlint-core_2.4.1.jar:na]
    at org.sonarsource.sonarlint.core.container.standalone.StandaloneGlobalContainer.analyze(StandaloneGlobalContainer.java:118) [org.sonarsource.sonarlint.core.sonarlint-core_2.4.1.jar:na]
    at org.sonarsource.sonarlint.core.StandaloneSonarLintEngineImpl.analyze(StandaloneSonarLintEngineImpl.java:93) [org.sonarsource.sonarlint.core.sonarlint-core_2.4.1.jar:na]
    at org.sonarsource.sonarlint.core.StandaloneSonarLintEngineImpl.analyze(StandaloneSonarLintEngineImpl.java:83) [org.sonarsource.sonarlint.core.sonarlint-core_2.4.1.jar:na]
    at org.sonarlint.eclipse.core.internal.jobs.StandaloneSonarLintClientFacade.runAnalysis(StandaloneSonarLintClientFacade.java:60) [org.sonarlint.eclipse.core_2.2.1.201608261350-RELEASE.jar:na]
    at org.sonarlint.eclipse.core.internal.jobs.AnalyzeProjectJob.run(AnalyzeProjectJob.java:463) [org.sonarlint.eclipse.core_2.2.1.201608261350-RELEASE.jar:na]
    at org.sonarlint.eclipse.core.internal.jobs.AnalyzeProjectJob$AnalysisThread.run(AnalyzeProjectJob.java:127) [org.sonarlint.eclipse.core_2.2.1.201608261350-RELEASE.jar:na]

如果我的感觉是正确的,你面临的这个bug已经在即将到来的4.2.1版本的SonarQube Java插件:https://jira.sonarsource.com/browse/SONARJAVA-1839修复。

相关内容

  • 没有找到相关文章

最新更新