< prev index next >

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

Print this page

        

@@ -31,11 +31,12 @@
     UnsafeStaticObjectFieldAccessorImpl(Field field) {
         super(field);
     }
 
     public Object get(Object obj) throws IllegalArgumentException {
-        return unsafe.getReference(base, fieldOffset);
+        return isFlattened() ? unsafe.getValue(base, fieldOffset, field.getType())
+                             : unsafe.getReference(base, fieldOffset);
     }
 
     public boolean getBoolean(Object obj) throws IllegalArgumentException {
         throw newGetBooleanIllegalArgumentException();
     }

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