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

WARNING: java.lang.System::load has been called by org.jline.nativ.JLineNativeLoader in an unnamed module #13030

Open
xuwei-k opened this issue Sep 3, 2024 · 4 comments
Milestone

Comments

@xuwei-k
Copy link

xuwei-k commented Sep 3, 2024

Reproduction steps

install jdk 24

$ java --version
openjdk 24-ea 2025-03-18
OpenJDK Runtime Environment (build 24-ea+13-1421)
OpenJDK 64-Bit Server VM (build 24-ea+13-1421, mixed mode, sharing)

launch Scala 2.13.14 REPL

Problem

$ scala
Welcome to Scala 2.13.14 (OpenJDK 64-Bit Server VM, Java 24-ea).
Type in expressions for evaluation. Or try :help.
WARNING: A restricted method in java.lang.System has been called
WARNING: java.lang.System::load has been called by org.jline.nativ.JLineNativeLoader in an unnamed module
WARNING: Use --enable-native-access=ALL-UNNAMED to avoid a warning for callers in this module
WARNING: Restricted methods will be blocked in a future release unless native access is enabled

https://openjdk.org/jeps/472

@lrytz
Copy link
Member

lrytz commented Sep 3, 2024

Thanks @xuwei-k! So IIUC we're getting the warning because Scala is not using the module system (ie, using the unnamed module), as well as jline. There would be no warning if the code using JNI was in a different module

Is there any other option than adding the --enable-native-access flag?

@sjrd
Copy link
Member

sjrd commented Sep 3, 2024

So IIUC we're getting the warning because Scala is not using the module system (ie, using the unnamed module)

I don't think so. AFAIU from the JEP, all code, whether in a module or not, is disallowed JNI by default. So regardless, you need a command-line option. The only difference that modules make is that you can grant specific modules access to JNI, without granting all of the code on the classpath. Whereas for code in the unnamed module, you have no choice but to grant JNI access to the entire classpath.

@SethTisue SethTisue added this to the 2.13.16 milestone Sep 3, 2024
@SethTisue
Copy link
Member

note sure whether this should also be reported to JLine 3 and perhaps to other repos such as Scala 3, scala-cli, sbt...

if we have to add --enable-native-access can that only be done at JVM start time? because if so it will need to be added by anything that might launch a Scala REPL

Yoshida-san did already open sbt/sbt#7634 but it's about ipcsocket rather than JLine

@lrytz
Copy link
Member

lrytz commented Sep 9, 2024

So IIUC we're getting the warning because Scala is not using the module system (ie, using the unnamed module)

AFAIU from the JEP, all code, whether in a module or not, is disallowed JNI by default

You're right, I got confused by this (from the JEP):

Code that merely calls a native method declared in a different module does not need to have native access enabled.

The JEP clearly says:

Library developers who rely on JNI or the FFM API should inform their users that they will need to enable native access using one of the methods below.

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