Class HotSpotVirtualMachine

java.lang.Object
com.sun.tools.attach.VirtualMachine
sun.tools.attach.HotSpotVirtualMachine
Direct Known Subclasses:
BsdVirtualMachine, LinuxVirtualMachine, SolarisVirtualMachine, WindowsVirtualMachine

public abstract class HotSpotVirtualMachine extends VirtualMachine
  • Method Details

    • loadAgentLibrary

      public void loadAgentLibrary(String agentLibrary, String options) throws AgentLoadException, AgentInitializationException, IOException
      Description copied from class: VirtualMachine
      Loads an agent library.

      A JVM TI client is called an agent. It is developed in a native language. A JVM TI agent is deployed in a platform specific manner but it is typically the platform equivalent of a dynamic library. This method causes the given agent library to be loaded into the target VM (if not already loaded). It then causes the target VM to invoke the Agent_OnAttach function as specified in the JVM Tools Interface specification. Note that the Agent_OnAttach function is invoked even if the agent library was loaded prior to invoking this method.

      The agent library provided is the name of the agent library. It is interpreted in the target virtual machine in an implementation-dependent manner. Typically an implementation will expand the library name into an operating system specific file name. For example, on UNIX systems, the name foo might be expanded to libfoo.so, and located using the search path specified by the LD_LIBRARY_PATH environment variable.

      If the Agent_OnAttach function in the agent library returns an error then an AgentInitializationException is thrown. The return value from the Agent_OnAttach can then be obtained by invoking the returnValue method on the exception.

      Specified by:
      loadAgentLibrary in class VirtualMachine
      Parameters:
      agentLibrary - The name of the agent library.
      options - The options to provide to the Agent_OnAttach function (can be null).
      Throws:
      AgentLoadException - If the agent library does not exist, or cannot be loaded for another reason.
      AgentInitializationException - If the Agent_OnAttach function returns an error
      IOException - If an I/O error occurs
      See Also:
    • loadAgentPath

      public void loadAgentPath(String agentLibrary, String options) throws AgentLoadException, AgentInitializationException, IOException
      Description copied from class: VirtualMachine
      Load a native agent library by full pathname.

      A JVM TI client is called an agent. It is developed in a native language. A JVM TI agent is deployed in a platform specific manner but it is typically the platform equivalent of a dynamic library. This method causes the given agent library to be loaded into the target VM (if not already loaded). It then causes the target VM to invoke the Agent_OnAttach function as specified in the JVM Tools Interface specification. Note that the Agent_OnAttach function is invoked even if the agent library was loaded prior to invoking this method.

      The agent library provided is the absolute path from which to load the agent library. Unlike loadAgentLibrary, the library name is not expanded in the target virtual machine.

      If the Agent_OnAttach function in the agent library returns an error then an AgentInitializationException is thrown. The return value from the Agent_OnAttach can then be obtained by invoking the returnValue method on the exception.

      Specified by:
      loadAgentPath in class VirtualMachine
      Parameters:
      agentLibrary - The full path of the agent library.
      options - The options to provide to the Agent_OnAttach function (can be null).
      Throws:
      AgentLoadException - If the agent library does not exist, or cannot be loaded for another reason.
      AgentInitializationException - If the Agent_OnAttach function returns an error
      IOException - If an I/O error occurs
      See Also:
    • loadAgent

      public void loadAgent(String agent, String options) throws AgentLoadException, AgentInitializationException, IOException
      Description copied from class: VirtualMachine
      Loads an agent.

      The agent provided to this method is a path name to a JAR file on the file system of the target virtual machine. This path is passed to the target virtual machine where it is interpreted. The target virtual machine attempts to start the agent as specified by the java.lang.instrument specification. That is, the specified JAR file is added to the system class path (of the target virtual machine), and the agentmain method of the agent class, specified by the Agent-Class attribute in the JAR manifest, is invoked. This method completes when the agentmain method completes.

      Specified by:
      loadAgent in class VirtualMachine
      Parameters:
      agent - Path to the JAR file containing the agent.
      options - The options to provide to the agent's agentmain method (can be null).
      Throws:
      AgentLoadException - If the agent does not exist, or cannot be started in the manner specified in the java.lang.instrument specification.
      AgentInitializationException - If the agentmain throws an exception
      IOException - If an I/O error occurs
    • getSystemProperties

      public Properties getSystemProperties() throws IOException
      Description copied from class: VirtualMachine
      Returns the current system properties in the target virtual machine.

      This method returns the system properties in the target virtual machine. Properties whose key or value is not a String are omitted. The method is approximately equivalent to the invocation of the method System.getProperties in the target virtual machine except that properties with a key or value that is not a String are not included.

      This method is typically used to decide which agent to load into the target virtual machine with loadAgent, or loadAgentLibrary. For example, the java.home or user.dir properties might be use to create the path to the agent library or JAR file.

      Specified by:
      getSystemProperties in class VirtualMachine
      Returns:
      The system properties
      Throws:
      IOException - If an I/O error occurs
      See Also:
    • getAgentProperties

      public Properties getAgentProperties() throws IOException
      Description copied from class: VirtualMachine
      Returns the current agent properties in the target virtual machine.

      The target virtual machine can maintain a list of properties on behalf of agents. The manner in which this is done, the names of the properties, and the types of values that are allowed, is implementation specific. Agent properties are typically used to store communication end-points and other agent configuration details. For example, a debugger agent might create an agent property for its transport address.

      This method returns the agent properties whose key and value is a String. Properties whose key or value is not a String are omitted. If there are no agent properties maintained in the target virtual machine then an empty property list is returned.

      Specified by:
      getAgentProperties in class VirtualMachine
      Returns:
      The agent properties
      Throws:
      IOException - If an I/O error occurs
    • localDataDump

      public void localDataDump() throws IOException
      Throws:
      IOException
    • remoteDataDump

      public InputStream remoteDataDump(Object... args) throws IOException
      Throws:
      IOException
    • dumpHeap

      public InputStream dumpHeap(Object... args) throws IOException
      Throws:
      IOException
    • heapHisto

      public InputStream heapHisto(Object... args) throws IOException
      Throws:
      IOException
    • setFlag

      public InputStream setFlag(String name, String value) throws IOException
      Throws:
      IOException
    • printFlag

      public InputStream printFlag(String name) throws IOException
      Throws:
      IOException
    • executeJCmd

      public InputStream executeJCmd(String command) throws IOException
      Throws:
      IOException