< prev index next >

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

Print this page
@@ -33,11 +33,12 @@
      UnsafeQualifiedStaticObjectFieldAccessorImpl(Field field, boolean isReadOnly) {
          super(field, isReadOnly);
      }
  
      public Object get(Object obj) throws IllegalArgumentException {
-         return unsafe.getReferenceVolatile(base, fieldOffset);
+         return isFlattened() ? unsafe.getValue(obj, fieldOffset, field.getType())
+                              : unsafe.getReferenceVolatile(base, fieldOffset, field.getType());
      }
  
      public boolean getBoolean(Object obj) throws IllegalArgumentException {
          throw newGetBooleanIllegalArgumentException();
      }

@@ -74,16 +75,16 @@
          throws IllegalArgumentException, IllegalAccessException
      {
          if (isReadOnly) {
              throwFinalFieldIllegalAccessException(value);
          }
-         if (value != null) {
-             if (!field.getType().isAssignableFrom(value.getClass())) {
-                 throwSetIllegalArgumentException(value);
-             }
+         checkValue(value);
+         if (isFlattened()) {
+             unsafe.putValue(base, fieldOffset, field.getType(), value);
+         } else {
+             unsafe.putReferenceVolatile(base, fieldOffset, value);
          }
-         unsafe.putReferenceVolatile(base, fieldOffset, value);
      }
  
      public void setBoolean(Object obj, boolean z)
          throws IllegalArgumentException, IllegalAccessException
      {
< prev index next >