public class Objects
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static int |
ADDRESS_SIZE |
static long |
ARRAY_BASE_OFFSET |
static int |
ARRAY_HEADER_SIZE |
static int |
ARRAY_INDEX_SCALE |
static long |
COMPRESSED_OOP_BASE |
static int |
COMPRESSED_OOP_SHIFT |
static boolean |
COMPRESSED_OOPS |
static long |
KLASS_OFFSET |
static int |
OBJECT_ALIGNMENT |
static int |
OBJECT_HEADER_SIZE |
static int |
OOP_SIZE |
| Constructor and Description |
|---|
Objects() |
| Modifier and Type | Method and Description |
|---|---|
static <T> T |
allocate(java.lang.Class<T> clazz)
Allocate an instance of the given class.
|
static <T> T |
cast(java.lang.Object o,
java.lang.Class<T> target)
Cast the given object to the given class.
|
static <T> T |
cast(java.lang.Object o,
long klass)
Cast the given object to the given class pointer.
|
static <T> T |
cast(java.lang.Object o,
java.lang.Object target)
Cast the given object to the given object.
|
static void |
copyMemory(java.lang.Object from,
long fromOffset,
java.lang.Object to,
long toOffset,
long size)
Copy the memory from one object to another with the given offsets.
|
static void |
copyMemory(java.lang.Object from,
java.lang.Object to,
long size)
Copy the memory from one object to another.
|
static <T> T |
fromAddress(long jvmAddress)
Deprecated.
|
static <T> T |
fromJVMAddress(long jvmAddress)
Get the object at the given jvm memory address.
|
static long |
getKlass(java.lang.Class<?> clazz)
Get the class pointer of the given class.
|
static long |
getKlass(java.lang.Object o)
Get the class pointer of the given object.
|
static long |
toAddress(java.lang.Object o)
Deprecated.
|
static long |
toJVMAddress(long nativeAddress)
Convert a native address to a jvm address.
|
static long |
toJVMAddress(java.lang.Object o)
Get the jvm memory address of an object.
|
static long |
toNativeAddress(long jvmAddress)
Convert a jvm address to a native address.
|
static long |
toNativeAddress(java.lang.Object o)
Get the native address of an object.
|
public static final long ARRAY_BASE_OFFSET
public static final int ARRAY_INDEX_SCALE
public static final int ADDRESS_SIZE
public static final int OOP_SIZE
public static final int OBJECT_HEADER_SIZE
public static final int ARRAY_HEADER_SIZE
public static final int OBJECT_ALIGNMENT
public static final boolean COMPRESSED_OOPS
public static final int COMPRESSED_OOP_SHIFT
public static final long COMPRESSED_OOP_BASE
public static final long KLASS_OFFSET
@Deprecated public static long toAddress(java.lang.Object o)
toJVMAddress(Object).public static long toJVMAddress(java.lang.Object o)
o - The objectInvalidOOPSizeException - If the OOP size is not 4 or 8public static long toJVMAddress(long nativeAddress)
nativeAddress - The native addresspublic static long toNativeAddress(java.lang.Object o)
o - The objectjava.lang.IllegalStateException - If the OOP size is not 4 or 8public static long toNativeAddress(long jvmAddress)
jvmAddress - The jvm address@Deprecated public static <T> T fromAddress(long jvmAddress)
fromJVMAddress(long).public static <T> T fromJVMAddress(long jvmAddress)
T - The type of the objectjvmAddress - The jvm memory addressInvalidOOPSizeException - If the OOP size is not 4 or 8public static void copyMemory(java.lang.Object from,
java.lang.Object to,
long size)
from - The source objectto - The target objectsize - The size of the memory to copypublic static void copyMemory(java.lang.Object from,
long fromOffset,
java.lang.Object to,
long toOffset,
long size)
from - The source objectfromOffset - The offset in the source objectto - The target objecttoOffset - The offset in the target objectsize - The size of the memory to copypublic static long getKlass(java.lang.Class<?> clazz)
clazz - The classjava.lang.InstantiationException - If the class can not be allocatedpublic static long getKlass(java.lang.Object o)
o - The objectInvalidOOPSizeException - If the OOP size is not 4 or 8public static <T> T cast(java.lang.Object o,
java.lang.Class<T> target)
T - The type of the objecto - The objecttarget - The target classpublic static <T> T cast(java.lang.Object o,
java.lang.Object target)
T - The type of the objecto - The objecttarget - The target objectpublic static <T> T cast(java.lang.Object o,
long klass)
T - The type of the objecto - The objectklass - The class pointerjava.lang.ClassCastException - If the object can not be castedjava.lang.UnsupportedOperationException - If the JVM is OpenJ9public static <T> T allocate(java.lang.Class<T> clazz)
T - The type of the instanceclazz - The classjava.lang.InstantiationException - If the class can not be allocatedjava.lang.ClassCastException - If the object does not match the given class