< prev index next >

src/java.base/share/classes/jdk/internal/reflect/UnsafeStaticObjectFieldAccessorImpl.java

Print this page

        

*** 31,41 **** UnsafeStaticObjectFieldAccessorImpl(Field field) { super(field); } public Object get(Object obj) throws IllegalArgumentException { ! return isFlattened ? unsafe.getValue(base, fieldOffset, field.getType()) : unsafe.getObject(base, fieldOffset); } public boolean getBoolean(Object obj) throws IllegalArgumentException { throw newGetBooleanIllegalArgumentException(); --- 31,41 ---- UnsafeStaticObjectFieldAccessorImpl(Field field) { super(field); } public Object get(Object obj) throws IllegalArgumentException { ! return isFlattened() ? unsafe.getValue(base, fieldOffset, field.getType()) : unsafe.getObject(base, fieldOffset); } public boolean getBoolean(Object obj) throws IllegalArgumentException { throw newGetBooleanIllegalArgumentException();
*** 73,90 **** throws IllegalArgumentException, IllegalAccessException { if (isFinal) { throwFinalFieldIllegalAccessException(value); } ! if (value != null) { ! if (!field.getType().isAssignableFrom(value.getClass())) { ! throwSetIllegalArgumentException(value); ! } ! } else if (field.getType().isValue()) { ! throw new NullPointerException("cannot set this field of type " + field.getType() + " to null"); ! } ! if (isFlattened) { unsafe.putValue(obj, fieldOffset, field.getType(), value); } else { unsafe.putObject(base, fieldOffset, value); } } --- 73,84 ---- throws IllegalArgumentException, IllegalAccessException { if (isFinal) { throwFinalFieldIllegalAccessException(value); } ! checkValue(value); ! if (isFlattened()) { unsafe.putValue(obj, fieldOffset, field.getType(), value); } else { unsafe.putObject(base, fieldOffset, value); } }
< prev index next >