You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$ 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
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?
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.
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
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.
Reproduction steps
install jdk 24
launch Scala 2.13.14 REPL
Problem
https://openjdk.org/jeps/472
The text was updated successfully, but these errors were encountered: