How to replace Unsafe.objectFieldOffset?

Viewed 514

I update jdk 8 to jdk 11 , how to replace Unsafe.objectFieldOffset

Math.max(size, unsafe.objectFieldOffset(f) + sizeOf(f));
1 Answers

sun.misc.Unsafe is a Critical Internal API which was not encapsulated in JDK 9:

These APIs are thus accessible by default to code on the class path, and accessible to code in modules if those modules declare dependences upon the jdk.unsupported module.

So, you can just continue using it.

Related