A terminally deprecated method in sun.misc.Unsafe has been called

#1

Hello, if I run the enhancer I 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.objectdb.o.OSH (file:/C:/Users/XXX/.gradle/caches/modules-2/files-2.1/com.objectdb/objectdb-jk/2.9.5/312b9e1cec120d4b8230be61f94bc4c422c681e9/objectdb-jk-2.9.5.jar)
WARNING: Please consider reporting this to the maintainers of class com.objectdb.o.OSH
WARNING: sun.misc.Unsafe::allocateMemory will be removed in a future release

#2

The warnings started appearing in Java 24. ObjectDB currently uses sun.misc.Unsafe internally as an optimization. However, current versions of ObjectDB should continue to work after this class is removed from Java in future JDK version (without the optimization).

This issue may not be specific to the Enhancer (which does not actually use sun.misc.Unsafe) but to ObjectDB in general. You may be seeing the error in the Enhancer because you are running it with a newer JDK than the one used for your application.

As a workaround until ObjectDB no longer uses sun.misc.Unsafe, you can suppress the warning by running Java with the following setting (which was the default in Java 23):

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

ObjectDB Support

Reply