< prev index next >

src/jdk.unsupported/share/classes/sun/misc/Unsafe.java

Print this page
@@ -893,10 +893,11 @@
       *
       * @see #getInt(Object, long)
       */
      @Deprecated(since="18", forRemoval=true)
      @ForceInline
+     @SuppressWarnings("preview")
      public long objectFieldOffset(Field f) {
          if (f == null) {
              throw new NullPointerException();
          }
          Class<?> declaringClass = f.getDeclaringClass();

@@ -904,10 +905,13 @@
              throw new UnsupportedOperationException("can't get field offset on a hidden class: " + f);
          }
          if (declaringClass.isRecord()) {
              throw new UnsupportedOperationException("can't get field offset on a record class: " + f);
          }
+         if (declaringClass.isValue()) {
+             throw new UnsupportedOperationException("can't get field offset on a value class: " + f);
+         }
          beforeMemoryAccess();
          return theInternalUnsafe.objectFieldOffset(f);
      }
  
      /**

@@ -933,10 +937,11 @@
       *
       * @see #getInt(Object, long)
       */
      @Deprecated(since="18", forRemoval=true)
      @ForceInline
+     @SuppressWarnings("preview")
      public long staticFieldOffset(Field f) {
          if (f == null) {
              throw new NullPointerException();
          }
          Class<?> declaringClass = f.getDeclaringClass();

@@ -944,10 +949,13 @@
              throw new UnsupportedOperationException("can't get field offset on a hidden class: " + f);
          }
          if (declaringClass.isRecord()) {
              throw new UnsupportedOperationException("can't get field offset on a record class: " + f);
          }
+         if (declaringClass.isValue()) {
+             throw new UnsupportedOperationException("can't get field offset on a value class: " + f);
+         }
          beforeMemoryAccess();
          return theInternalUnsafe.staticFieldOffset(f);
      }
  
      /**

@@ -965,10 +973,11 @@
       * offset and object reference to a heap memory accessor will be removed
       * in a future release. Use {@link VarHandle} instead.
       */
      @Deprecated(since="18", forRemoval=true)
      @ForceInline
+     @SuppressWarnings("preview")
      public Object staticFieldBase(Field f) {
          if (f == null) {
              throw new NullPointerException();
          }
          Class<?> declaringClass = f.getDeclaringClass();

@@ -976,10 +985,13 @@
              throw new UnsupportedOperationException("can't get base address on a hidden class: " + f);
          }
          if (declaringClass.isRecord()) {
              throw new UnsupportedOperationException("can't get base address on a record class: " + f);
          }
+         if (declaringClass.isValue()) {
+             throw new UnsupportedOperationException("can't get field offset on a value class: " + f);
+         }
          beforeMemoryAccess();
          return theInternalUnsafe.staticFieldBase(f);
      }
  
      /**
< prev index next >