Starting in JDK 24 or 25, using any of these methods will produce a warning. Some time after JDK 25 they will stop working altogether. We need a replacement. There are three options:
1. Use Java arrays, meaning the memory would now be on the heap
2. Use direct NIO buffers for off-heap memory, ByteBuffer.allocateDirect
3. Use FFM as defined in JEP 454 [2]
Option 1 will likely be the least-performant option, and is at least as much work as option 2, so is likely not the best choice.
Option 2 should be pretty straight-forward to implement, at least for the memory allocation and access methods, and should be evaluated for performance.
Option 3 is the best long-term replacement, but will require adopting JDK 22 as the minimum version of JDK for JavaFX. This is something we could consider in the JavaFX 24 or 25 time frame, so this option should also be evaluated.
[1] https://openjdk.org/jeps/471
[2] https://openjdk.org/jeps/454
- duplicates
-
JDK-8345121 JavaFX: WARNING: A terminally deprecated method in sun.misc.Unsafe has been called
-
- Closed
-
- is blocked by
-
JDK-8340003 Bump minimum JDK version for JavaFX to JDK 22
-
- Resolved
-
- relates to
-
JDK-8359259 Missing range checks in Marlin for JavaFX
-
- Open
-
-
JDK-8334138 Suppress removal warnings for sun.misc.Unsafe memory access methods
-
- Resolved
-
-
JDK-8345127 Add --sun-misc-unsafe-memory-access=allow when running tests until JDK-8334137 is fixed
-
- Resolved
-
-
JDK-8359260 Optimizations for Marlin FFM in JavaFX
-
- Open
-
-
JDK-8334161 Enable -Werror for javac tasks to fail on any warnings
-
- Resolved
-
-
JDK-8331670 Deprecate the Memory-Access Methods in sun.misc.Unsafe for Removal
-
- Resolved
-
- links to
-
Commit(master) openjdk/jfx/72c1c21a
-
Review(master) openjdk/jfx/1814