Support Java 17 in the Sonar Maven Plugin

Hi,

Currently, when running sonar analysis using sonar-maven-plugin 3.9.0.2155 in maven 3.8.3 and JDK 17 (AWS Corretto) we get the following error

[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.9.0.2155:sonar (default-cli) on project exchange-service: Execution default-cli of goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.9.0.2155:sonar failed: An API incompatibility was encountered while executing org.sonarsource.scanner.maven:sonar-maven-plugin:3.9.0.2155:sonar: java.lang.ExceptionInInitializerError: null
[ERROR] -----------------------------------------------------
[ERROR] realm =    plugin>org.sonarsource.scanner.maven:sonar-maven-plugin:3.9.0.2155
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls[0] = file:/Users/meliad2/.m2/repository/org/sonarsource/scanner/maven/sonar-maven-plugin/3.9.0.2155/sonar-maven-plugin-3.9.0.2155.jar
[ERROR] urls[1] = file:/Users/meliad2/.m2/repository/org/sonatype/plexus/plexus-sec-dispatcher/1.4/plexus-sec-dispatcher-1.4.jar
[ERROR] urls[2] = file:/Users/meliad2/.m2/repository/org/sonatype/plexus/plexus-cipher/1.4/plexus-cipher-1.4.jar
[ERROR] urls[3] = file:/Users/meliad2/.m2/repository/org/codehaus/plexus/plexus-utils/3.2.1/plexus-utils-3.2.1.jar
[ERROR] urls[4] = file:/Users/meliad2/.m2/repository/org/sonarsource/scanner/api/sonar-scanner-api/2.16.1.361/sonar-scanner-api-2.16.1.361.jar
[ERROR] urls[5] = file:/Users/meliad2/.m2/repository/commons-lang/commons-lang/2.6/commons-lang-2.6.jar
[ERROR] Number of foreign imports: 1
[ERROR] import: Entry[import  from realm ClassRealm[maven.api, parent: null]]
[ERROR] 
[ERROR] -----------------------------------------------------
[ERROR] : java.lang.reflect.InaccessibleObjectException-->Unable to make protected final java.lang.Class java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain) throws java.lang.ClassFormatError accessible: module java.base does not "opens java.lang" to unnamed module @1ce6a9bd

Would it be possible to support Java 17 in the sonar maven plugin?

Thanks

Hi @davidmelia ,

I’ve tried to analyze a project locally with mvn 3.8.3, openjdk version "17" 2021-09-14, sonar-maven-plugin 3.9.0.2155, and SonarQube 9.1 without any issue. Could you try locally and give a bit more details to help reproduce the issue?

@mpaladin and in the current LTS version ? Do you plan to include the Java17 support ? If not when will be the next LTS version with Java17 support ?
Thanks in advance for your feedbacks :wink:

Thanks @mpaladin

I can confirm that this is a problem only when using SonarQube Server 7.9.1 and after upgrading to SonarQube Server 9.1 the problem is solved.

I didn’t realise there was a relationship from the server to the maven plugin which could cause this type of issue.

Thanks for your help :slight_smile:

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