JDK-8345121 : JavaFX: WARNING: A terminally deprecated method in sun.misc.Unsafe has been called
  • Type: Bug
  • Component: javafx
  • Sub-Component: graphics
  • Affected Version: jfx24
  • Priority: P2
  • Status: Open
  • Resolution: Unresolved
  • Submitted: 2024-11-27
  • Updated: 2025-05-05
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
jfx25Unresolved
Related Reports
Duplicate :  
Relates :  
Relates :  
Relates :  
Sub Tasks
JDK-8346566 :  
Description
To reproduce this, use JDK 24 to run any JavaFX application that renders a control or a complex shape, for example, HelloButton (in rt/appls/toys/Hello). You will get the following warning

WARNING: A terminally deprecated method in sun.misc.Unsafe has been called
WARNING: sun.misc.Unsafe::allocateMemory has been called by com.sun.marlin.OffHeapArray (file:.../sdk/lib/javafx.graphics.jar)
WARNING: Please consider reporting this to the maintainers of class com.sun.marlin.OffHeapArray
WARNING: sun.misc.Unsafe::allocateMemory will be removed in a future release

As described in JDK-8334137, the Marlin rasterizer uses sun.misc.Unsafe to allocate off-heap memory. JEP 471 [1] deprecated for removal all of the memory-access methods in sun.misc.Unsafe as of JDK 23. 

JEP 498 [2] prints a warning on use of any memory-access methods in sun.misc.Unsafe in JDK 24. This warning can be disabled by "--sun-misc-unsafe-memory-access=allow" in JDK 24. We *must* eliminate our use of sun.misc.Unsafe by fixing JDK-8334137 as soon as possible -- ideally in JavaFX 24 and no later than JavaFX 25.

In the mean time, we will use this bug to inform application developers that they can run java with the following flag to avoid the warning:

java --sun-misc-unsafe-memory-access=allow

[1] https://openjdk.org/jeps/471
[2] https://openjdk.org/jeps/498
Comments
At this point in the release, it seems unlikely that we will have a fix for JDK-8334137 in JavaFX 24, so I created the release note sub-task in anticipation of needing it. I will wait until RDP1 (Jan 16th) to actually write the release note.
18-12-2024

This issue exists for the sole purpose of having a release note to describe the workaround. We intend to eventually close this issue as a Duplicate of JDK-8334137, once that issue is fixed. If JDK-8334137 is fixed in JavaFX 24, then I will remove the release-note=yes label from this issue, since we will have no need for a release note. If JDK-8334137 is fixed in JavaFX 25, then I will provide a release note for this issue, under a "Known Issues" section, documenting the workaround.
27-11-2024