62

I'm upgrading java version in our production code from java 8 to java 11.

I have to add the below JDK module configuration in the application java start command due to usage of third party libraries like flume, zookeeper etc.

--add-opens java.base/java.lang=ALL-UNNAMED --add-opens jdk.management/com.sun.management.internal=ALL-UNNAMED

After adding this configuration and java application is starting fine.

But when I run the tests using mvn test the tests are failing. I've added the below configuration to the maven-surefire-plugin but still it is throwing error.

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>3.0.0-M5</version>
    <configuration>
        <argLine>--illegal-access=permit</argLine>
        <argLine>--add-opens java.base/java.lang=ALL-UNNAMED</argLine>
        <argLine>--add-opens jdk.management/com.sun.management.internal=ALL-UNNAMED</argLine>
        <argLine>-Dillegal-access=permit</argLine>
    </configuration>
</plugin>

I think I'm not passing the argument correctly in the maven test. Any idea what I'm doing wrong and how to fix this?

1 Answer 1

65

It is a single argLine, like:

<argLine>
    --add-exports org.junit.platform.commons/org.junit.platform.commons.util=ALL-UNNAMED
    --add-exports org.junit.platform.commons/org.junit.platform.commons.logging=ALL-UNNAMED
</argLine>
Sign up to request clarification or add additional context in comments.

2 Comments

Do you know how to add when using Gradle?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.