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.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Interface Description
      static class  VirtualMachine.AbstractBase
      An abstract base implementation for a virtual machine.
      static class  VirtualMachine.ForHotSpot
      A virtual machine attachment implementation for a HotSpot VM or any compatible JVM.
      static class  VirtualMachine.ForOpenJ9
      A virtual machine attachment implementation for OpenJ9 or any compatible JVM.
      static class  VirtualMachine.Resolver
      A resolver for the current VM's virtual machine attachment emulation.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void detach()
      Detaches this virtual machine representation.
      java.util.Properties getAgentProperties()
      Loads the target VMs agent properties.
      java.util.Properties getSystemProperties()
      Loads the target VMs system properties.
      void loadAgent​(java.lang.String jarFile)
      Loads an agent into the represented virtual machine.
      void loadAgent​(java.lang.String jarFile, java.lang.String argument)
      Loads an agent into the represented virtual machine.
      void loadAgentLibrary​(java.lang.String library)
      Loads a native agent library into the represented virtual machine.
      void loadAgentLibrary​(java.lang.String library, java.lang.String argument)
      Loads a native agent library into the represented virtual machine.
      void loadAgentPath​(java.lang.String path)
      Loads a native agent into the represented virtual machine.
      void loadAgentPath​(java.lang.String path, java.lang.String argument)
      Loads a native agent into the represented virtual machine.
      java.lang.String startLocalManagementAgent()
      Starts a local management agent.
      void startManagementAgent​(java.util.Properties properties)
      Starts a JMX management agent.
    • Method Detail

      • getSystemProperties

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

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

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

        void loadAgent​(java.lang.String jarFile,
                       java.lang.String argument)
                throws java.io.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:
        java.io.IOException - If an I/O exception occurs.
      • loadAgentPath

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

        void loadAgentPath​(java.lang.String path,
                           java.lang.String argument)
                    throws java.io.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:
        java.io.IOException - If an I/O exception occurs.
      • loadAgentLibrary

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

        void loadAgentLibrary​(java.lang.String library,
                              java.lang.String argument)
                       throws java.io.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:
        java.io.IOException - If an I/O exception occurs.
      • startManagementAgent

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

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

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