Open Matzz opened 5 months ago
You need to set Universal / javaOptions += "-J--add-opensss=java.base/sun.nio.ch=ALL-UNNAMED"
I had trouble with this too. I tried all sorts of formatting for the strings with javaOptions
and when it didn't throw formatting errors, it never seemed to use the java options I added.
I finally got it working by setting the JDK_JAVA_OPTIONS
env variable in the project settings in build.sbt:
.settings(
envVars ++= Map("JDK_JAVA_OPTIONS" -> "--add-opens=java.base/sun.nio.ch=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED ")
)
Try these settings:
javaOptions += "--add-opens=java.base/sun.nio.ch=ALL-UNNAMED"
// fork tests in order to pick up javaOptions when running tests
Test / fork := true
// these will be added to conf/application.ini and picked up by the script
Universal / javaOptions += "-J--add-opens=java.base/sun.nio.ch=ALL-UNNAMED"
Expected behaviour
I need to set
--add-opens=java.base/sun.nio.ch=ALL-UNNAMED
for my application.Actual behaviour
When I set
javaOptions += "-J--add-opensss=java.base/sun.nio.ch=ALL-UNNAMED"
it fails withUnrecognized option: -J--add-opensss=java.base/sun.nio.ch=ALL-UNNAMED
during the tests. SettingjavaOptions += "--add-opens=java.base/sun.nio.ch=ALL-UNNAMED"
does not fail but app fails withjava.lang.reflect.InaccessibleObjectException: Unable to make field private final java.util.Set sun.nio.ch.SelectorImpl.selectedKeys accessible: module java.base does not \"opens sun.nio.ch\" ....
So ut seems that--add-opens
was not applied to jvm configuration.Information