When they say "restrict" they mean "gate the feature behind a flag"
Prepare the Java ecosystem for a future release that disallows interoperation with native code by default, whether via JNI or the FFM API. As of that release, application developers will have to explicitly enable the use of JNI and the FFM API at startup.
and
It is not a goal to deprecate JNI or to remove JNI from the Java Platform.
and
any interaction at all between Java code and native code is risky because it can compromise the integrity of applications and of the Java Platform itself. According to the policy of integrity by default, all JDK features that are capable of breaking integrity must obtain explicit approval from the application's developer.
Which imo is very silly, because the app is already running on the system. They nixxed the Java sandbox stuff because it was always futile, no they're using a similar justification to disable JNI.
Not to mention there's plenty of platform specific stuff in Java as it is already, small things that you need to be cognizant of at times.
Those uses result in warnings as well, there are safe replacements for most of Unsafe already. It's going to be a long migration, but every journey has to start somewhere.
Which is better, it issuing a warning and failing to even start until you properly understand what's the matter, or it randomly failing to work, or even cause more serious harm during production?
Better is not requiring the tool that praises itself on write once run anywhere to not remove/disable major features/place them behind a flag. Java will never be able to do everything people use JNI (and the newer FFI) for out of the box. If you distribute a jar to your users, now they have to open a command line to pass a flag each time they want to run your app.
166
u/NotABot1235 Mar 18 '25 edited Mar 18 '25
New features include the following:
404: Generational Shenandoah (Experimental)
450: Compact Object Headers (Experimental)
472: Prepare to Restrict the Use of JNI
475: Late Barrier Expansion for G1
478: Key Derivation Function API (Preview)
479: Remove the Windows 32-bit x86 Port
483: Ahead-of-Time Class Loading & Linking
484: Class-File API
485: Stream Gatherers
486: Permanently Disable the Security Manager
487: Scoped Values (Fourth Preview)
488: Primitive Types in Patterns, instanceof, and switch (Second Preview)
489: Vector API (Ninth Incubator)
490: ZGC: Remove the Non-Generational Mode
491: Synchronize Virtual Threads without Pinning
492: Flexible Constructor Bodies (Third Preview)
493: Linking Run-Time Images without JMODs
494: Module Import Declarations (Second Preview)
495: Simple Source Files and Instance Main Methods (Fourth Preview)
496: Quantum-Resistant Module-Lattice-Based Key Encapsulation Mechanism
497: Quantum-Resistant Module-Lattice-Based Digital Signature Algorithm
498: Warn upon Use of Memory-Access Methods in sun.misc.Unsafe
499: Structured Concurrency (Fourth Preview)
501: Deprecate the 32-bit x86 Port for Removal
https://jdk.java.net/24/
JDK 25 will be the next LTS and release in 6 months.