Open xuwei-k opened 2 months ago
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 https://github.com/sbt/sbt/issues/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.
JLine ticket is https://github.com/jline/jline3/issues/1067
The discussion there seems to confirm that we need to start the JVM with --enable-native-access=ALL-UNNAMED
Reproduction steps
install jdk 24
launch Scala 2.13.14 REPL
Problem
https://openjdk.org/jeps/472