Interface VirtualMachine

All Known Implementing Classes:
VirtualMachine.AbstractBase, VirtualMachine.ForHotSpot, VirtualMachine.ForOpenJ9

public interface VirtualMachine

An implementation for attachment on a virtual machine. This interface mimics the tooling API's virtual machine interface to allow for similar usage by ByteBuddyAgent where all calls are made via reflection such that this structural typing suffices for interoperability.

Note: Implementations are required to declare a static method attach(String) returning an instance of a class that declares the methods defined by VirtualMachine.

  • Method Details

    • getSystemProperties

      Properties getSystemProperties() throws IOException
      Loads the target VMs system properties.
      Returns:
      The target VM properties.
      Throws:
      IOException - If an I/O exception occurs.
    • getAgentProperties

      Properties getAgentProperties() throws IOException
      Loads the target VMs agent properties.
      Returns:
      The target VM properties.
      Throws:
      IOException - If an I/O exception occurs.
    • loadAgent

      void loadAgent(String jarFile) throws IOException
      Loads an agent into the represented virtual machine.
      Parameters:
      jarFile - The jar file to attach.
      Throws:
      IOException - If an I/O exception occurs.
    • loadAgent

      void loadAgent(String jarFile, @MaybeNull String argument) throws IOException
      Loads an agent into the represented virtual machine.
      Parameters:
      jarFile - The jar file to attach.
      argument - The argument to provide or null if no argument should be provided.
      Throws:
      IOException - If an I/O exception occurs.
    • loadAgentPath

      void loadAgentPath(String path) throws IOException
      Loads a native agent into the represented virtual machine.
      Parameters:
      path - The agent path.
      Throws:
      IOException - If an I/O exception occurs.
    • loadAgentPath

      void loadAgentPath(String path, @MaybeNull String argument) throws IOException
      Loads a native agent into the represented virtual machine.
      Parameters:
      path - The agent path.
      argument - The argument to provide or null if no argument should be provided.
      Throws:
      IOException - If an I/O exception occurs.
    • loadAgentLibrary

      void loadAgentLibrary(String library) throws IOException
      Loads a native agent library into the represented virtual machine.
      Parameters:
      library - The agent library.
      Throws:
      IOException - If an I/O exception occurs.
    • loadAgentLibrary

      void loadAgentLibrary(String library, @MaybeNull String argument) throws IOException
      Loads a native agent library into the represented virtual machine.
      Parameters:
      library - The agent library.
      argument - The argument to provide or null if no argument should be provided.
      Throws:
      IOException - If an I/O exception occurs.
    • startManagementAgent

      void startManagementAgent(Properties properties) throws IOException
      Starts a JMX management agent.
      Parameters:
      properties - The properties to transfer to the JMX agent.
      Throws:
      IOException - If an I/O error occurs.
    • startLocalManagementAgent

      String startLocalManagementAgent() throws IOException
      Starts a local management agent.
      Returns:
      The local connector address.
      Throws:
      IOException - If an I/O error occurs.
    • detach

      void detach() throws IOException
      Detaches this virtual machine representation.
      Throws:
      IOException - If an I/O exception occurs.