--- old/src/jdk.unsupported/share/classes/sun/misc/Unsafe.java 2020-01-27 10:49:54.000000000 -0800 +++ new/src/jdk.unsupported/share/classes/sun/misc/Unsafe.java 2020-01-27 10:49:53.000000000 -0800 @@ -637,6 +637,12 @@ */ @ForceInline public long objectFieldOffset(Field f) { + if (f == null) { + throw new NullPointerException(); + } + if (f.getDeclaringClass().isHiddenClass()) { + throw new UnsupportedOperationException("can't get field offset on a hidden class: " + f); + } return theInternalUnsafe.objectFieldOffset(f); } @@ -659,6 +665,12 @@ */ @ForceInline public long staticFieldOffset(Field f) { + if (f == null) { + throw new NullPointerException(); + } + if (f.getDeclaringClass().isHiddenClass()) { + throw new UnsupportedOperationException("can't get field offset on a hidden class: " + f); + } return theInternalUnsafe.staticFieldOffset(f); } @@ -674,6 +686,12 @@ */ @ForceInline public Object staticFieldBase(Field f) { + if (f == null) { + throw new NullPointerException(); + } + if (f.getDeclaringClass().isHiddenClass()) { + throw new UnsupportedOperationException("can't get base address on a hidden class: " + f); + } return theInternalUnsafe.staticFieldBase(f); }