TypeSymbol on test classes are not available after migration to java plugin version

We are using SonarQube Server Community Edition for analyzing our code base. Since a couple of years now, we also develop custom java rule, extending the sonar java plugin. As we are considering migrating to the latest SonarQube Server verion 9.7, I’m currently migrating our 53 custom java rules to the new Sonarqube plugin API version an Sonar Java Plugin version.

So, I am migrating the following dependencies in our pom.xml:

Sonar Java Plugin

Dependency Old Version New Version
Sonar Java Plugin org.sonarsource.java:sonar-java-plugin: org.sonarsource.java:sonar-java-plugin:
Sonar Plugin API Impl org.sonarsource.sonarqube:sonar-plugin-api-impl: org.sonarsource.sonarqube:sonar-plugin-api-impl:
Sonar Plugin API org.sonarsource.sonarqube:sonar-plugin-api: org.sonarsource.api.plugin:sonar-plugin-api:

NB: new group id for sonar plugin api and different versions betwenn api implementation and api!

After migration my Sonar plugin workspace to the new versions, I encounter the problem, that for some of my test classes - the classes that are analyzed by the rules - no TypeSymbols are available anymore. This causes a failure of the tests which rely on these symbol information:

Debugging the execution I found the following differences:

Old Version

New Version

I didn’t change anything else. The test classes are in the same workspace under the folder “src/test/java” and are compiled during the build process. The class files should be available, when running the tests as in other cases, the symbol is not unknown.

In the example above, I’m trying to evaluate a method call on a method defined in a super class. Maybe the problem lies in this constellation, but I can’t imagine why.

Any help would be appreciated!

Kindest regards

Hi @tschindler,
Sorry for coming back so late to the issue.
Are you still experiencing this problem? Are the .class files picked up by sonar.java.test.binaries or sonar.java.binaries during the analysis?

Hi @Dorian_Burihabwa,

thank you very much for your answer. I actually do not really know, where to put that properties, so that the test runner picks it up.

I use Maven with the surefire plugin for running the tests:


Do you know where to put the property there?

Thank you very much!

Hello @Dorian_Burihabwa

and anyone else reading this post. I finally found the cause for my problems. Probably there werde some changes in the java-checks-testkit, I’m using a wrapper for running the tests, wrapping the call of “CheckVerifier.newVerifier()”. In this wrapper I compute the classpath to hand over to the test with the
“.withClassPass(List classpath)”. Probably there were some changes in the implementation of the InternalCheckVerifier class of the testkit.

Now I have to add the target directory of the combiled test classes to make the tests running without a failure. That solved my problem.

Glad to read you could find an answer to your problem

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