Analyzing Java8 code with JDK11 - deprecations

  • ALM used: Bitbucket Cloud
  • CI system used: Jenkins
  • Steps to reproduce

We’re trying to move to SonarScanner based on JDK11 for a Java8 project.
We face multiple deprecation warnings about the code like this
new Integer(...)
Class.forName(...).newInstance();
The problem is that those methods are not deprecated in JDK1.8 (while they’re in JDK11).
How to correctly solve the issue?
Setting sonar.java.source explicitly = 1.8 didn’t help.

1 Like

I have the same problem.

Hello there,

Sorry for the very long time you had to wait before getting an answer. This is, unfortunately, a known issue, on which we are currently (and finally) working. The JDK analyzed by the project being not the same one used during the analysis, and consequently reporting issues that are not fixable.

Hopefully, our next Java Analyzer release should allow us to be able to handle these cases correctly, and not report FPs of this kind anymore. You can track the ticket here: SONARJAVA-3056

Cheers,
Michael

1 Like

Thanks Michael!

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