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

JDK 24: REPL prints warning on startup about JLineNativeLoader #22756

Open
alanbur opened this issue Mar 9, 2025 · 11 comments
Open

JDK 24: REPL prints warning on startup about JLineNativeLoader #22756

alanbur opened this issue Mar 9, 2025 · 11 comments
Labels
area:repl compat:java:jep:stable Issues corresponding to a JEP which got already delivered as a stable feature in a JDK release compat:java:jep Issues corresponding to a JEP (JDK Enhancement Proposal) compat:java itype:enhancement

Comments

@alanbur
Copy link

alanbur commented Mar 9, 2025

:
According to https://docs.scala-lang.org/overviews/jdk-compatibility/overview.html, Scala 3.6.4 is compatible with Java 24, yet:

$ scala
WARNING: A terminally deprecated method in sun.misc.Unsafe has been called
WARNING: sun.misc.Unsafe::objectFieldOffset has been called by scala.runtime.LazyVals$ (file:/data/opt/periscope-tools-1.1.0/scala3-3.6.4/maven2/org/scala-lang/scala3-library_3/3.6.4/scala3-library_3-3.6.4.jar)
WARNING: Please consider reporting this to the maintainers of class scala.runtime.LazyVals$
WARNING: sun.misc.Unsafe::objectFieldOffset will be removed in a future release
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 (file:/data/opt/periscope-tools-1.1.0/scala3-3.6.4/maven2/org/jline/jline-native/3.27.1/jline-native-3.27.1.jar)
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

Welcome to Scala 3.6.4 (24, Java Java HotSpot(TM) 64-Bit Server VM).
Type in expressions for evaluation. Or try :help.
                                                                                                                                                                            
scala> 
@alanbur alanbur added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Mar 9, 2025
@SethTisue
Copy link
Member

SethTisue commented Mar 9, 2025

it will still work, it's just printing warnings — two different ones — both of which you can safely ignore

the LazyVal thing is described at https://www.scala-lang.org/blog/next-scala-lts.html and work on it is being tracked at #9013

for the JLine one we have a Scala 2 ticket at scala/bug#13030. but it's good to have a Scala 3 ticket as well, thank you. I've changed the title of this ticket to just be about the JLine warning. there are some remarks on the Scala 2 ticket about what the root cause is and what's needed to address it

@SethTisue SethTisue changed the title Scala 3.6.4 is supposed to be JDK24 compatible, but isn't JDK 24: REPL prints warning on startup about JLineNativeLoader Mar 9, 2025
@alanbur
Copy link
Author

alanbur commented Mar 9, 2025

Thanks for the info Seth.

I note #9013 says "problematic for various reasons (e.g. usage of a security manager, using Graal Native (#13985)).", I don't think that's an issue any more, my app is built using Native Image and I don't see that problem.

However, unfortunately these warnings are deal-breakers for me, I'm shipping a CLI utility that will require JDK24 for its next release and I can't have it spewing warnings when it runs. What I haven't figured out is if it's possible to suppress the warnings.

@SethTisue
Copy link
Member

SethTisue commented Mar 9, 2025

I can't have it spewing warnings when it runs

You shouldn't see the JLine one; that’s specific to the REPL.

(Whether you'll see the LazyVal one, I don't know; but let's keep this ticket specific to the REPL issue, please.)

@alanbur
Copy link
Author

alanbur commented Mar 9, 2025

I've confirmed that the JLine one only seems to affect the REPL. I think I've found a workaround for the LazyVal warning, I'll add a note to #9013.

@alanbur
Copy link
Author

alanbur commented Mar 9, 2025

This seems to suppress the warnings for the REPL:

e$ export JDK_JAVA_OPTIONS='--sun-misc-unsafe-memory-access=allow --enable-native-access=ALL-UNNAMED'
$ scala
NOTE: Picked up JDK_JAVA_OPTIONS: --sun-misc-unsafe-memory-access=allow --enable-native-access=ALL-UNNAMED
Welcome to Scala 3.6.4 (24, Java Java HotSpot(TM) 64-Bit Server VM).
Type in expressions for evaluation. Or try :help.
                                                                                                                                                      
scala> 

Well, sort of works - I'm not sure where the NOTE: comes from.

@SethTisue
Copy link
Member

I wouldn't expect that you'd need to go through JDK_JAVA_OPTIONS; I would expect scala -J --sun-misc-unsafe-memory-access=allow to work. @Gedochao seems like a bug in Scala-CLI — would you agree?

@alanbur
Copy link
Author

alanbur commented Mar 9, 2025

This seems to work, just providing the single flag above doesn't:

$ scala -J --sun-misc-unsafe-memory-access=allow -J --enable-native-access=ALL-UNNAMED
Welcome to Scala 3.6.4 (24, Java Java HotSpot(TM) 64-Bit Server VM).
Type in expressions for evaluation. Or try :help.
                                                                                                                                              
scala> 

@SethTisue
Copy link
Member

Oh, weird! I was testing on JDK 25, where I see:

% scala -J --sun-misc-unsafe-memory-access=allow -J --enable-native-access=ALL-UNNAMED
WARNING: A terminally deprecated method in sun.misc.Unsafe has been called
WARNING: sun.misc.Unsafe::objectFieldOffset has been called by scala.runtime.LazyVals$ (file:/opt/homebrew/Cellar/scala/3.6.4/libexec/libexec/scala-cli.jar)
WARNING: Please consider reporting this to the maintainers of class scala.runtime.LazyVals$
WARNING: sun.misc.Unsafe::objectFieldOffset will be removed in a future release
Welcome to Scala 3.6.4 (25-ea, Java OpenJDK 64-Bit Server VM).
Type in expressions for evaluation. Or try :help.

Not sure how to account for the difference, unless it's the 24 vs 25 thing. (I don't have a 24 installation easily accessible at the moment.)

@alanbur
Copy link
Author

alanbur commented Mar 9, 2025

Yeah, weird indeed. But if there's one way that works for 24 and a different way for 25, that's probably good enough for now :-)

@Gedochao Gedochao added stat:needs fix upstream Progress on ticket needs a fix in an upstream dependency. and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Mar 10, 2025
@Gedochao
Copy link
Contributor

@SethTisue I do not think it's a Scala CLI issue, the options seem to be passed correctly... let me know if there's reason to think otherwise. Might be a JDK 24 vs JDK 25 thing, indeed.

@Gedochao Gedochao added compat:java compat:java:jep Issues corresponding to a JEP (JDK Enhancement Proposal) compat:java:jep:stable Issues corresponding to a JEP which got already delivered as a stable feature in a JDK release labels Mar 10, 2025
@Gedochao
Copy link
Contributor

Gedochao commented Mar 10, 2025

@Gedochao Gedochao added itype:enhancement and removed itype:bug stat:needs fix upstream Progress on ticket needs a fix in an upstream dependency. labels Mar 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:repl compat:java:jep:stable Issues corresponding to a JEP which got already delivered as a stable feature in a JDK release compat:java:jep Issues corresponding to a JEP (JDK Enhancement Proposal) compat:java itype:enhancement
Projects
None yet
Development

No branches or pull requests

3 participants