fury
fury copied to clipboard
java memory.Platform uses terminally deprecated Unsafe api
Search before asking
- [x] I had searched in the issues and found no similar issues.
Version
Since JDK 24, the sun.misc.Unsafe.arrayBaseOffset api is terminally deprecated for removal:
WARNING: A terminally deprecated method in sun.misc.Unsafe has been called
WARNING: sun.misc.Unsafe::arrayBaseOffset has been called by org.apache.fury.memory.Platform (file:/home/steven/.m2/repository/org/apache/fury/fury-core/0.10.0/fury-core-0.10.0.jar)
WARNING: Please consider reporting this to the maintainers of class org.apache.fury.memory.Platform
WARNING: sun.misc.Unsafe::arrayBaseOffset will be removed in a future release
For now, this is only a warning. In the future this will fail entirely.
Component(s)
Java
Minimal reproduce step
Any usage of Fury e.g. ThreadSafeFury.deserialize under JDK 24, as far as I understand
What did you expect to see?
Using Fury should not print warnings about using terminally deprecated methods.
What did you see instead?
A warning that the Unsafe.arrayBaseOffset api is deprecated for removal :)
Anything Else?
No response
Are you willing to submit a PR?
- [ ] I'm willing to submit a PR!
The replacement for this API still use Unsafe:
static VarHandle makeArrayElementHandle(Class<?> arrayClass) {
if (!arrayClass.isArray())
throw new IllegalArgumentException("not an array: " + arrayClass);
Class<?> componentType = arrayClass.getComponentType();
int aoffset = (int) UNSAFE.arrayBaseOffset(arrayClass);
int ascale = UNSAFE.arrayIndexScale(arrayClass);
int ashift = 31 - Integer.numberOfLeadingZeros(ascale);
We can wait when this API is really removed, and use the implementation in VarHandle