4

My unit tests fail when I migrate from java8 to java 17. Here is an example of exceptions I get:

Unable to make java.io.OptionalDataException(boolean) accessible: module java.base does not "opens java.io" to unnamed module

When I googled, I found that I had to add the "--add-opens java.base/java.io=ALL-UNNAMED" option as an argument to the JVM.

Here is how I did:

<plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>${surefire.version}</version>
            <configuration>
                <argLine>--add-opens java.base/java.lang=ALL-UNNAMED</argLine>
                <argLine>--add-opens java.base/java.util=ALL-UNNAMED</argLine>
                <argLine>--add-opens java.base/java.io=ALL-UNNAMED</argLine>
            </configuration>

        </plugin>

But I still have always the same issue :( any help ?

Aguid
  • 943
  • 2
  • 10
  • 24

1 Answers1

6

For me it worked just to combine the arguments in one statement:

<argLine>--add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED</argLine>
mdm
  • 61
  • 1
  • 2