Package org.openjdk.jol.vm
Interface VirtualMachine
-
- All Known Implementing Classes:
HotspotUnsafe
public interface VirtualMachine
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description long
addressOf(java.lang.Object obj)
Returns the machine address of the given object.int
addressSize()
Returns native address size.int
arrayBaseOffset(java.lang.String arrayComponentKlass)
Returns the array base offset for an array of a given component type.int
arrayHeaderSize()
Returns the array header size.int
arrayIndexScale(java.lang.String arrayComponentKlass)
Returns the array index scale for an array of a given component type.int
classPointerSize()
Returns class pointer size.java.lang.String
details()
Returns the informational details about the current VM modelong
fieldOffset(java.lang.reflect.Field field)
Returns the field offset for a given field, starting from the object base.boolean
getBoolean(java.lang.Object obj, long offset)
Reads a boolean off the object at given offset.byte
getByte(java.lang.Object obj, long offset)
Reads a byte off the object at given offset.char
getChar(java.lang.Object obj, long offset)
Reads a char off the object at given offset.double
getDouble(java.lang.Object obj, long offset)
Reads a double off the object at given offset.float
getFloat(java.lang.Object obj, long offset)
Reads a float off the object at given offset.int
getInt(java.lang.Object obj, long offset)
Reads an int off the object at given offset.long
getLong(java.lang.Object obj, long offset)
Reads a long off the object at given offset.java.lang.Object
getObject(java.lang.Object obj, long offset)
Reads an object off the object at given offset.short
getShort(java.lang.Object obj, long offset)
Reads a short off the object at given offset.int
objectAlignment()
Returns the object alignment.int
objectHeaderSize()
Returns the object header size.long
sizeOf(java.lang.Object obj)
Returns the shallow size of the given object.long
sizeOfField(java.lang.String klass)
Returns the size of a field holding the type.
-
-
-
Method Detail
-
sizeOf
long sizeOf(java.lang.Object obj)
Returns the shallow size of the given object.- Parameters:
obj
- object- Returns:
- shallow size
-
sizeOfField
long sizeOfField(java.lang.String klass)
Returns the size of a field holding the type.- Parameters:
klass
- klass- Returns:
- slot size
-
addressOf
long addressOf(java.lang.Object obj)
Returns the machine address of the given object. Note that in some VM modes, the addresses would be guesses, based on internal experiments which would try to figure out the reference encoding. Use this data with care. Doing the naked memory access on the result of this method may corrupt the memory.- Parameters:
obj
- object- Returns:
- address
-
fieldOffset
long fieldOffset(java.lang.reflect.Field field)
Returns the field offset for a given field, starting from the object base.- Parameters:
field
- field- Returns:
- offset
-
arrayBaseOffset
int arrayBaseOffset(java.lang.String arrayComponentKlass)
Returns the array base offset for an array of a given component type.- Parameters:
arrayComponentKlass
- component type- Returns:
- base offset
-
arrayIndexScale
int arrayIndexScale(java.lang.String arrayComponentKlass)
Returns the array index scale for an array of a given component type.- Parameters:
arrayComponentKlass
- component type- Returns:
- index scale
-
objectAlignment
int objectAlignment()
Returns the object alignment.- Returns:
- object alignment
-
objectHeaderSize
int objectHeaderSize()
Returns the object header size.- Returns:
- header size
-
arrayHeaderSize
int arrayHeaderSize()
Returns the array header size. This includes the array length pseudofield.- Returns:
- array header size
-
addressSize
int addressSize()
Returns native address size.- Returns:
- address size in bytes
-
classPointerSize
int classPointerSize()
Returns class pointer size.- Returns:
- class pointer size, in bytes
-
getBoolean
boolean getBoolean(java.lang.Object obj, long offset)
Reads a boolean off the object at given offset.- Parameters:
obj
- instanceoffset
- offset- Returns:
- the boolean
-
getByte
byte getByte(java.lang.Object obj, long offset)
Reads a byte off the object at given offset.- Parameters:
obj
- instanceoffset
- offset- Returns:
- the byte
-
getShort
short getShort(java.lang.Object obj, long offset)
Reads a short off the object at given offset.- Parameters:
obj
- instanceoffset
- offset- Returns:
- the short
-
getChar
char getChar(java.lang.Object obj, long offset)
Reads a char off the object at given offset.- Parameters:
obj
- instanceoffset
- offset- Returns:
- the char
-
getInt
int getInt(java.lang.Object obj, long offset)
Reads an int off the object at given offset.- Parameters:
obj
- instanceoffset
- offset- Returns:
- the int
-
getFloat
float getFloat(java.lang.Object obj, long offset)
Reads a float off the object at given offset.- Parameters:
obj
- instanceoffset
- offset- Returns:
- the float
-
getLong
long getLong(java.lang.Object obj, long offset)
Reads a long off the object at given offset.- Parameters:
obj
- instanceoffset
- offset- Returns:
- the long
-
getDouble
double getDouble(java.lang.Object obj, long offset)
Reads a double off the object at given offset.- Parameters:
obj
- instanceoffset
- offset- Returns:
- the double
-
getObject
java.lang.Object getObject(java.lang.Object obj, long offset)
Reads an object off the object at given offset.- Parameters:
obj
- instanceoffset
- offset- Returns:
- the Object
-
details
java.lang.String details()
Returns the informational details about the current VM mode- Returns:
- String details
-
-