Java >= 9 specific issue raised for Java 8 maven submodule

Hi SonarQube team,

I’m using SonarQube 8.9LTS by analyzing a multi-module maven project.
It’s a Java 15 project unless the api submodule that is configured with maven.compile.source=1.8

When analyzing this project, some issues are raised on my Java 8 submodule by the rule Deprecated annotations should include explanations which is specific to Java >= 9.

According to the doc:

Java analysis is able to react to the java version used for sources. This feature allows the deactivation of rules that target higher versions of Java than the one in use in the project so that false positives aren’t generated from irrelevant rules.

The feature relies entirely on the sonar.java.source property, which is automatically filled by most of the scanners used for analyses (Maven, Gradle). Java version-specific rules are not disabled when sonar.java.source is not provided. Concretely, rules which are designed to target specific java versions (tagged “java7” or “java8”) are activated by default in the Sonar Way Java profile. From a user perspective, the feature is fully automatic, but it means that you probably want your projects to be correctly configured.

So any ideas why it’s not working for me?

With :heart:
Xavier

Hi Xavier,

Could you add -Dsonar.scanner.dumpToFile=[file path] to your analysis command & post the results (you may need to redact them…) so we can see what properties the scanner is getting? I would expect the Java version set at the module level to be read/honored by the scanner, so let’s start by seeing if the scanner is getting that value.

 
Ann