< prev index next >
src/java.base/share/classes/jdk/internal/reflect/UnsafeQualifiedStaticObjectFieldAccessorImpl.java
Print this page
*** 33,43 ****
UnsafeQualifiedStaticObjectFieldAccessorImpl(Field field, boolean isReadOnly) {
super(field, isReadOnly);
}
public Object get(Object obj) throws IllegalArgumentException {
! return isFlattened ? unsafe.getValue(obj, fieldOffset, field.getType())
: unsafe.getObjectVolatile(base, fieldOffset);
}
public boolean getBoolean(Object obj) throws IllegalArgumentException {
throw newGetBooleanIllegalArgumentException();
--- 33,43 ----
UnsafeQualifiedStaticObjectFieldAccessorImpl(Field field, boolean isReadOnly) {
super(field, isReadOnly);
}
public Object get(Object obj) throws IllegalArgumentException {
! return isFlattened() ? unsafe.getValue(obj, fieldOffset, field.getType())
: unsafe.getObjectVolatile(base, fieldOffset);
}
public boolean getBoolean(Object obj) throws IllegalArgumentException {
throw newGetBooleanIllegalArgumentException();
*** 75,93 ****
throws IllegalArgumentException, IllegalAccessException
{
if (isReadOnly) {
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(base, fieldOffset, field.getType(), value);
} else {
unsafe.putObjectVolatile(base, fieldOffset, value);
}
}
--- 75,86 ----
throws IllegalArgumentException, IllegalAccessException
{
if (isReadOnly) {
throwFinalFieldIllegalAccessException(value);
}
! checkValue(value);
! if (isFlattened()) {
unsafe.putValue(base, fieldOffset, field.getType(), value);
} else {
unsafe.putObjectVolatile(base, fieldOffset, value);
}
}
< prev index next >