< prev index next >

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

Print this page
@@ -28,11 +28,10 @@
  import jdk.internal.vm.annotation.ForceInline;
  import jdk.internal.misc.VM;
  import jdk.internal.reflect.CallerSensitive;
  import jdk.internal.reflect.Reflection;
  
- import java.lang.invoke.MethodHandles;
  import java.lang.reflect.Field;
  import java.util.Set;
  
  
  /**

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

@@ -653,10 +653,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);
+         }
          return theInternalUnsafe.objectFieldOffset(f);
      }
  
      /**
       * Reports the location of a given static field, in conjunction with {@link

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

@@ -692,10 +696,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);
+         }
          return theInternalUnsafe.staticFieldOffset(f);
      }
  
      /**
       * Reports the location of a given static field, in conjunction with {@link

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

@@ -723,10 +731,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);
+         }
          return theInternalUnsafe.staticFieldBase(f);
      }
  
      /**
       * Reports the offset of the first element in the storage allocation of a
< prev index next >