Reputation: 67474
I am effectively asking this question, but for the spring-boot:run
goal: how to pass --add-opens JDK module configuration to maven test
For context, I'm trying to execute spring-boot 1.5.1.RELEASE code that was written for jdk1.8 in jdk16. JDK 9 introduced the concept of modules, and this was a backwards incompatible change, though from my research, it looks like there are workarounds. When I run the code, I get this error:
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
Rather than add modules to this old project, I want to get past this with minimal modification to the existing project. What do I have to do to run my application without adding modules? one workaround I know would work is to download JDK 8 and run the code with that, but that doesn't seem like a good solution.
Upvotes: 1
Views: 4011
Reputation: 67474
I think I found an answer, but I'd like to know if there's a better way:
<build>
<finalName>project</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<jvmArguments>--add-opens java.base/java.lang=ALL-UNNAMED</jvmArguments>
</configuration>
</plugin>
</plugins>
</build>
Upvotes: 7