Azure DevOps Run Code Analysis error java.lang.UnsupportedClassVersionError

  • SonarQube: 7.3.0.15553
  • Task Version: 4.36.1
  • SonarScanner for MSBuild: 5.15.1

Starting today, Azure DevOps builds have been getting the following error during the Run Code Analysis step (Prepare Analysis Configuration step succeeds without error):

“##[error]Exception in thread “main” java.lang.UnsupportedClassVersionError: org/sonarsource/scanner/cli/Main has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0”
RunCode Analysis Task Error log.txt (9.5 KB)

Hi,

Your version is past EOL. You should upgrade to either the latest version or the current LTA (long-term active version) at your earliest convenience. Your upgrade path is:

7.3 → 7.9.6 → -> 8.9.10 → 9.9.4 → 10.5.1 (last step optional)

You may find these resources helpful:

If you have questions about upgrading, feel free to open a new thread for that here.

If your error persists after upgrade, please come back to us.

My understanding is that support for Java 8 (class file version 52.0) is deprecated in all scanner versions after 9.X, wouldn’t upgrading just ensure that I get this error and not resolve it?

In fact, opening the logs it looks like you’re using v9.5, not v7.3. So that’s already the case for you.

2023-03-25T13:52:54.9484541Z INFO: Analyzing on SonarQube server 9.5.0.56709

This is still end of life, and ought to be updated to v9.9 LTA.

In any case, I suggest you make sure you’re using v5 or v6 of the Azure DevOps Extension Tasks and, if neccessary, set the [JDK version to JAVA_HOME_11_X64 or JAVA_HOME_17_X64.