Skip to content

Conversation

@wfouche
Copy link
Member

@wfouche wfouche commented Sep 5, 2025

Fixes #21 when using Java 24 or Java 25

@wfouche
Copy link
Member Author

wfouche commented Oct 2, 2025

@jeff5 , this is the next PR to prioritize.

The fix supresses these two warning messages when Java 24 or Java 25 is detected:

$ jbang run jython-cli@jython
WARNING: A restricted method in java.lang.System has been called
WARNING: java.lang.System::load has been called by com.kenai.jffi.internal.StubLoader in an unnamed module (file:/home/wfouche/.m2/repository/com/github/jnr/jffi/1.3.13/jffi-1.3.13.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

WARNING: A terminally deprecated method in sun.misc.Unsafe has been called
WARNING: sun.misc.Unsafe::putLong has been called by com.kenai.jffi.UnsafeMemoryIO$UnsafeMemoryIO64 (file:/home/wfouche/.m2/repository/com/github/jnr/jffi/1.3.13/jffi-1.3.13.jar)
WARNING: Please consider reporting this to the maintainers of class com.kenai.jffi.UnsafeMemoryIO$UnsafeMemoryIO64
WARNING: sun.misc.Unsafe::putLong will be removed in a future release
Jython 2.7.4 (tags/v2.7.4:3f256f4a7, Aug 18 2024, 16:49:39)
[OpenJDK 64-Bit Server VM (Eclipse Adoptium)] on java25
Type "help", "copyright", "credits" or "license" for more information.

Also see https://openjdk.org/jeps/498

@wfouche
Copy link
Member Author

wfouche commented Oct 2, 2025

Console output when using Java 23

$ jbang run jython-cli@jython
Jython 2.7.4 (tags/v2.7.4:3f256f4a7, Aug 18 2024, 16:49:39)
[OpenJDK 64-Bit Server VM (Eclipse Adoptium)] on java23.0.2
Type "help", "copyright", "credits" or "license" for more information.
>>> 

Console output when using Java 24

$ jbang run jython-cli@jython
WARNING: A restricted method in java.lang.System has been called
WARNING: java.lang.System::load has been called by com.kenai.jffi.internal.StubLoader in an unnamed module (file:/home/wfouche/.m2/repository/com/github/jnr/jffi/1.3.13/jffi-1.3.13.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

WARNING: A terminally deprecated method in sun.misc.Unsafe has been called
WARNING: sun.misc.Unsafe::putLong has been called by com.kenai.jffi.UnsafeMemoryIO$UnsafeMemoryIO64 (file:/home/wfouche/.m2/repository/com/github/jnr/jffi/1.3.13/jffi-1.3.13.jar)
WARNING: Please consider reporting this to the maintainers of class com.kenai.jffi.UnsafeMemoryIO$UnsafeMemoryIO64
WARNING: sun.misc.Unsafe::putLong will be removed in a future release
Jython 2.7.4 (tags/v2.7.4:3f256f4a7, Aug 18 2024, 16:49:39)
[OpenJDK 64-Bit Server VM (Eclipse Adoptium)] on java24.0.2
Type "help", "copyright", "credits" or "license" for more information.
>>> 

Console output when using Java 25

$ jbang run jython-cli@jython
WARNING: A restricted method in java.lang.System has been called
WARNING: java.lang.System::load has been called by com.kenai.jffi.internal.StubLoader in an unnamed module (file:/home/wfouche/.m2/repository/com/github/jnr/jffi/1.3.13/jffi-1.3.13.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

WARNING: A terminally deprecated method in sun.misc.Unsafe has been called
WARNING: sun.misc.Unsafe::putLong has been called by com.kenai.jffi.UnsafeMemoryIO$UnsafeMemoryIO64 (file:/home/wfouche/.m2/repository/com/github/jnr/jffi/1.3.13/jffi-1.3.13.jar)
WARNING: Please consider reporting this to the maintainers of class com.kenai.jffi.UnsafeMemoryIO$UnsafeMemoryIO64
WARNING: sun.misc.Unsafe::putLong will be removed in a future release
Jython 2.7.4 (tags/v2.7.4:3f256f4a7, Aug 18 2024, 16:49:39)
[OpenJDK 64-Bit Server VM (Eclipse Adoptium)] on java24.0.2
Type "help", "copyright", "credits" or "license" for more information.
>>> 

@jeff5
Copy link
Member

jeff5 commented Oct 2, 2025

I'm broadly against suppressing warnings. This code will break in a later version of Java: best not pretend otherwise. Thanks however for testing.

If you have a way of avoiding the problem they warn us of, that's a different matter.

@wfouche
Copy link
Member Author

wfouche commented Oct 2, 2025

This is a warning message for the developers of Jython, and not the users of Jython. It says that an updated version of jffi is needed and this seems to be work in progress: jnr/jffi#165

Why bother the Jython user with warnings, if they can do nothing about it and it also do not affect them at the moment?

It makes for a cleaner user experience, so that is why I am in favour of suppressing these two warning (for now).

@wfouche wfouche closed this Oct 2, 2025
@jeff5
Copy link
Member

jeff5 commented Oct 5, 2025

Why bother the Jython user with warnings, if they can do nothing about it and it also do not affect them at the moment?

It's so they know it will break if they move up to Java 26, and they can press JNR/JFFI. I'm pretty sure this is what's in the mind of the JDK developers.

@wfouche wfouche deleted the dev/java-24-25 branch October 11, 2025 18:19
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

Successfully merging this pull request may close these issues.

Restricted and deprecated methods called

2 participants