< prev index next >

src/jdk.unsupported/share/classes/sun/misc/Unsafe.java

Print this page

        

*** 635,644 **** --- 635,650 ---- * must preserve all bits of static field offsets. * @see #getInt(Object, long) */ @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); } /** * Reports the location of a given static field, in conjunction with {@link
*** 657,666 **** --- 663,678 ---- * this method reports its result as a long value. * @see #getInt(Object, long) */ @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); } /** * Reports the location of a given static field, in conjunction with {@link
*** 672,681 **** --- 684,699 ---- * not be used in any way except as argument to the get and put routines in * this class. */ @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); } /** * Detects if the given class may need to be initialized. This is often
< prev index next >