< prev index next >

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

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

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