Interface VirtualMachine
- All Known Implementing Classes:
HotspotUnsafe
public interface VirtualMachine
-
Method Summary
Modifier and TypeMethodDescriptionlongReturns the machine address of the given object.intReturns native address size.intarrayBaseOffset(String arrayComponentKlass) Returns the array base offset for an array of a given component type.intReturns the array header size.intarrayIndexScale(String arrayComponentKlass) Returns the array index scale for an array of a given component type.intReturns class pointer size.details()Returns the informational details about the current VM modelongfieldOffset(Field field) Returns the field offset for a given field, starting from the object base.booleangetBoolean(Object obj, long offset) Reads a boolean off the object at given offset.byteReads a byte off the object at given offset.charReads a char off the object at given offset.doubleReads a double off the object at given offset.floatReads a float off the object at given offset.intReads an int off the object at given offset.longReads a long off the object at given offset.Reads an object off the object at given offset.shortReads a short off the object at given offset.intReturns the object alignment.intReturns the object header size.longReturns the shallow size of the given object.longsizeOfField(String klass) Returns the size of a field holding the type.
-
Method Details
-
sizeOf
Returns the shallow size of the given object.- Parameters:
obj- object- Returns:
- shallow size
-
sizeOfField
Returns the size of a field holding the type.- Parameters:
klass- klass- Returns:
- slot size
-
addressOf
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
Returns the field offset for a given field, starting from the object base.- Parameters:
field- field- Returns:
- offset
-
arrayBaseOffset
Returns the array base offset for an array of a given component type.- Parameters:
arrayComponentKlass- component type- Returns:
- base offset
-
arrayIndexScale
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
Reads a boolean off the object at given offset.- Parameters:
obj- instanceoffset- offset- Returns:
- the boolean
-
getByte
Reads a byte off the object at given offset.- Parameters:
obj- instanceoffset- offset- Returns:
- the byte
-
getShort
Reads a short off the object at given offset.- Parameters:
obj- instanceoffset- offset- Returns:
- the short
-
getChar
Reads a char off the object at given offset.- Parameters:
obj- instanceoffset- offset- Returns:
- the char
-
getInt
Reads an int off the object at given offset.- Parameters:
obj- instanceoffset- offset- Returns:
- the int
-
getFloat
Reads a float off the object at given offset.- Parameters:
obj- instanceoffset- offset- Returns:
- the float
-
getLong
Reads a long off the object at given offset.- Parameters:
obj- instanceoffset- offset- Returns:
- the long
-
getDouble
Reads a double off the object at given offset.- Parameters:
obj- instanceoffset- offset- Returns:
- the double
-
getObject
-
details
String details()Returns the informational details about the current VM mode- Returns:
- String details
-