< prev index next >

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

Print this page
@@ -889,10 +889,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();

@@ -900,10 +901,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);
      }
  
      /**

@@ -929,10 +933,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();

@@ -940,10 +945,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);
      }
  
      /**

@@ -961,10 +969,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();

@@ -972,10 +981,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 >