Package org.openjdk.jol.vm
Interface VirtualMachine
- All Known Implementing Classes:
HotspotUnsafe
public interface VirtualMachine
-
Method Summary
Modifier and TypeMethodDescriptionlong
Returns the machine address of the given object.int
Returns native address size.int
arrayBaseOffset
(String arrayComponentKlass) Returns the array base offset for an array of a given component type.int
Returns the array header size.int
arrayIndexScale
(String arrayComponentKlass) Returns the array index scale for an array of a given component type.int
Returns class pointer size.details()
Returns the informational details about the current VM modelong
fieldOffset
(Field field) Returns the field offset for a given field, starting from the object base.boolean
getBoolean
(Object obj, long offset) Reads a boolean off the object at given offset.byte
Reads a byte off the object at given offset.char
Reads a char off the object at given offset.double
Reads a double off the object at given offset.float
Reads a float off the object at given offset.int
Reads an int off the object at given offset.long
Reads a long off the object at given offset.Reads an object off the object at given offset.short
Reads a short off the object at given offset.int
Returns the object alignment.int
Returns the object header size.long
Returns the shallow size of the given object.long
sizeOfField
(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
Reads an object off the object at given offset.- Parameters:
obj
- instanceoffset
- offset- Returns:
- the Object
-
details
String details()Returns the informational details about the current VM mode- Returns:
- String details
-