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
$ jshell -C-Xplugin:fluent
An exception has occurred in the compiler (17.0.2). Please file a bug against the Java compiler via the Java bug reporting page (http://bugreport.java.com) after checking the Bug Database (http://bugs.java.com) for duplicates. Include your program, the following diagnostic, and the parameters passed to the Java compiler in your report. Thank you.
java.lang.NoClassDefFoundError: sun/misc/Unsafe
at com.sun.tools.javac.comp.Fluent.init(Fluent.java:26)
at jdk.compiler/com.sun.tools.javac.api.BasicJavacTask.initPlugin(BasicJavacTask.java:255)
at jdk.compiler/com.sun.tools.javac.api.BasicJavacTask.initPlugins(BasicJavacTask.java:229)
...
We need to replace Unsafe to be future proof anyway.
We can replace com.sun.misc with jdk.internals.misc, and use -J--add-opens=java.base/jdk.internal.misc=ALL-UNNAMED to start the plugin, but still fails with jshell:
$ jshell -C-Xplugin:fluent -J--add-opens=java.base/jdk.internal.misc=ALL-UNNAMED
Exception in thread "main" java.lang.InternalError: Exception during analyze - java.lang.NullPointerException: Cannot invoke "java.io.InputStream.available()" because "<local3>" is null
...
Caused by: java.lang.NullPointerException: Cannot invoke "java.io.InputStream.available()" because "<local3>" is null
at com.sun.tools.javac.comp.Fluent.reload(Fluent.java:57)
at com.sun.tools.javac.comp.Fluent.init(Fluent.java:40)
... 27 more
jshell inits the plugin for every invocation: easily fixed with a null check
jshell uses it's own custom resolver: not so easy to fix:
Exception in thread "main" java.lang.InternalError: Exception during analyze - java.lang.ClassCastException: class com.sun.tools.javac.comp.Fluent$FluentResolve cannot be cast to class jdk.jshell.TaskFactory$DisableAccessibilityResolve (com.sun.tools.javac.comp.Fluent$FluentResolve is in module jdk.compiler of loader 'app'; jdk.jshell.TaskFactory$DisableAccessibilityResolve is in module jdk.jshell of loader 'app')
rogerkeays
changed the title
jshell can't load fluent: java.lang.NoClassDefFoundError: sun/misc/Unsafe
implement jshell support
Jul 5, 2023
We need to replace Unsafe to be future proof anyway.
Unsafe source: https://github.com/openjdk/jdk/blob/master/src/jdk.unsupported/share/classes/sun/misc/Unsafe.java
The text was updated successfully, but these errors were encountered: