Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot set --add-opens jvm setting #1604

Open
Matzz opened this issue Apr 15, 2024 · 3 comments
Open

Cannot set --add-opens jvm setting #1604

Matzz opened this issue Apr 15, 2024 · 3 comments

Comments

@Matzz
Copy link

Matzz commented Apr 15, 2024

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 with Unrecognized option: -J--add-opensss=java.base/sun.nio.ch=ALL-UNNAMED during the tests.
Setting javaOptions += "--add-opens=java.base/sun.nio.ch=ALL-UNNAMED" does not fail but app fails with java.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

  • What sbt-native-packager are you using
    1.9.16
  • What sbt version
    1.9.6
  • What is your build system (e.g. Ubuntu, MacOS, Windows, Debian )
    MacOS
  • What package are you building (e.g. docker, rpm, ...)
    docker
  • What is your target system (e.g. Ubuntu 16.04, CentOS 7)
    Linux Alpine
@jtjeferreira
Copy link
Contributor

You need to set Universal / javaOptions += "-J--add-opensss=java.base/sun.nio.ch=ALL-UNNAMED"

@rkovalik-raft
Copy link

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 ")
)

@dwickern
Copy link
Collaborator

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"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants