java 17 corretto: `--add-opens` doesn't work

2.2k views Asked by At

I'm trying to migrate a Spring Boot, Kotlin project to java 17 from 8. We are using a communication framework that I'm trying to keep as-is for now. The library is using reflection to access URL.host and URL.authority This breaks at runtime with java.lang.reflect.InaccessibleObjectException: Unable to make field private java.lang.String java.net.URL.host accessible: module java.base does not "opens java.net" to unnamed module @3857f613

I tried adding --add-opens java.base/java.net=ALL-UNNAMED to the java command line but the exception is still raised.

Is there another setting for corretto?

Thanks, Amos

1

There are 1 answers

0
Евгений Лукинский On

try to use --add-opens java.base/java.net.URL=ALL-UNNAMED

for example it was my solution in similar case (for surefire plugin)

<argLine>
    --add-opens java.base/java.util.concurrent=ALL-UNNAMED
    --add-opens java.base/java.util.concurrent.atomic=ALL-UNNAMED
</argLine>