次のクラスを検討してください。
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:\Workspaces\E2pr\trunk-complete\e2pr-server\main\tools\src\com\icon\scp\tools\SqAnalysisTest.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]