Aguid
Aguid

Reputation: 1043

Migration to java17 issue : module java.base does not "opens java.io" to unnamed module

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 ?

Upvotes: 5

Views: 20474

Answers (1)

mdm
mdm

Reputation: 81

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>

Upvotes: 8

Related Questions