Interface VirtualMachine

All Known Implementing Classes:
HotspotUnsafe

public interface VirtualMachine
  • Method Summary

    Modifier and Type
    Method
    Description
    long
    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.
    Returns the informational details about the current VM mode
    long
    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
    getByte(Object obj, long offset)
    Reads a byte off the object at given offset.
    char
    getChar(Object obj, long offset)
    Reads a char off the object at given offset.
    double
    getDouble(Object obj, long offset)
    Reads a double off the object at given offset.
    float
    getFloat(Object obj, long offset)
    Reads a float off the object at given offset.
    int
    getInt(Object obj, long offset)
    Reads an int off the object at given offset.
    long
    getLong(Object obj, long offset)
    Reads a long off the object at given offset.
    getObject(Object obj, long offset)
    Reads an object off the object at given offset.
    short
    getShort(Object obj, long offset)
    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
    Returns the size of a field holding the type.
  • Method Details

    • sizeOf

      long sizeOf(Object obj)
      Returns the shallow size of the given object.
      Parameters:
      obj - object
      Returns:
      shallow size
    • sizeOfField

      long sizeOfField(String klass)
      Returns the size of a field holding the type.
      Parameters:
      klass - klass
      Returns:
      slot size
    • addressOf

      long addressOf(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(Field field)
      Returns the field offset for a given field, starting from the object base.
      Parameters:
      field - field
      Returns:
      offset
    • arrayBaseOffset

      int arrayBaseOffset(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(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(Object obj, long offset)
      Reads a boolean off the object at given offset.
      Parameters:
      obj - instance
      offset - offset
      Returns:
      the boolean
    • getByte

      byte getByte(Object obj, long offset)
      Reads a byte off the object at given offset.
      Parameters:
      obj - instance
      offset - offset
      Returns:
      the byte
    • getShort

      short getShort(Object obj, long offset)
      Reads a short off the object at given offset.
      Parameters:
      obj - instance
      offset - offset
      Returns:
      the short
    • getChar

      char getChar(Object obj, long offset)
      Reads a char off the object at given offset.
      Parameters:
      obj - instance
      offset - offset
      Returns:
      the char
    • getInt

      int getInt(Object obj, long offset)
      Reads an int off the object at given offset.
      Parameters:
      obj - instance
      offset - offset
      Returns:
      the int
    • getFloat

      float getFloat(Object obj, long offset)
      Reads a float off the object at given offset.
      Parameters:
      obj - instance
      offset - offset
      Returns:
      the float
    • getLong

      long getLong(Object obj, long offset)
      Reads a long off the object at given offset.
      Parameters:
      obj - instance
      offset - offset
      Returns:
      the long
    • getDouble

      double getDouble(Object obj, long offset)
      Reads a double off the object at given offset.
      Parameters:
      obj - instance
      offset - offset
      Returns:
      the double
    • getObject

      Object getObject(Object obj, long offset)
      Reads an object off the object at given offset.
      Parameters:
      obj - instance
      offset - offset
      Returns:
      the Object
    • details

      String details()
      Returns the informational details about the current VM mode
      Returns:
      String details