after migration from jdk17 to jdk21 junit is failing and ignoring surefire arling arguments for --add-open java.lang and junit fails throwing InaccessbleObjectException
Affected version
jdk21 maven version is 3.9.9 maven-compiler-plugin.version=3.14.0,Jacoco Version 0.8.11, aven Surefire Plugin 3.1.2
Bug description
We have migrated our springboot project from jdk17 to jdk21. In pom I have changed 1. jdk version to 21, 2. <maven-compiler-plugin.version>3.14.0 3. jacoco.version> 0.8.11 in
I took help of github.maven chat and used following in my pom.xml
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.11</version>
<executions>
<execution>
<id>prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.1.2</version>
<configuration>
<argLine>${jacoco.argLine} --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.lang.reflect=ALL-UNNAMED</argLine>
</configuration>
</plugin>
still junit is failing and --add-opens is ignored
@kavita369 Hello maam, I would like to solve this issue plss assign me
@kavita369 Hello Maam i have raised an pull request to solve this issue can you plss review it it would be helpful
I fill that it is not a problem in Maven itself but rather in project.
Can you provide a simple project which can reproduce your issue?
The use of --add-opens java.base/java.lang=ALL-UNNAMED is strongly discouraged. This is really asking for trouble, as the Java platform is progressively becoming more and more strict on integrity with new releases.