< prev index next > src/jdk.unsupported/share/classes/sun/misc/Unsafe.java
Print this page
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;
/**
*
* @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();
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
*
* @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();
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
* 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();
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 >