< prev index next >

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

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

*** 72,16 ***
          throws IllegalArgumentException, IllegalAccessException
      {
          if (isFinal) {
              throwFinalFieldIllegalAccessException(value);
          }
!         if (value != null) {
!             if (!field.getType().isAssignableFrom(value.getClass())) {
!                 throwSetIllegalArgumentException(value);
!             }
          }
-         unsafe.putReference(base, fieldOffset, value);
      }
  
      public void setBoolean(Object obj, boolean z)
          throws IllegalArgumentException, IllegalAccessException
      {
--- 73,16 ---
          throws IllegalArgumentException, IllegalAccessException
      {
          if (isFinal) {
              throwFinalFieldIllegalAccessException(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 >