Package sun.tools.attach
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
-
-
Field Summary
Fields Modifier and Type Field Description private static int
ATTACH_ERROR_BADJAR
private static int
ATTACH_ERROR_NOTONCP
private static int
ATTACH_ERROR_STARTFAIL
private long
attachTimeout
private static long
defaultAttachTimeout
private static int
JNI_ENOMEM
-
Constructor Summary
Constructors Constructor Description HotSpotVirtualMachine(AttachProvider provider, java.lang.String id)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description (package private) long
attachTimeout()
java.io.InputStream
dumpHeap(java.lang.Object... args)
(package private) abstract java.io.InputStream
execute(java.lang.String cmd, java.lang.Object... args)
private java.io.InputStream
executeCommand(java.lang.String cmd, java.lang.Object... args)
java.io.InputStream
executeJCmd(java.lang.String command)
java.util.Properties
getAgentProperties()
Returns the current agent properties in the target virtual machine.java.util.Properties
getSystemProperties()
Returns the current system properties in the target virtual machine.java.io.InputStream
heapHisto(java.lang.Object... args)
void
loadAgent(java.lang.String agent, java.lang.String options)
Loads an agent.private void
loadAgentLibrary(java.lang.String agentLibrary, boolean isAbsolute, java.lang.String options)
void
loadAgentLibrary(java.lang.String agentLibrary, java.lang.String options)
Loads an agent library.void
loadAgentPath(java.lang.String agentLibrary, java.lang.String options)
Load a native agent library by full pathname.void
localDataDump()
java.io.InputStream
printFlag(java.lang.String name)
(package private) int
readInt(java.io.InputStream in)
java.io.InputStream
remoteDataDump(java.lang.Object... args)
java.io.InputStream
setFlag(java.lang.String name, java.lang.String value)
-
Methods inherited from class com.sun.tools.attach.VirtualMachine
attach, attach, detach, equals, hashCode, id, list, loadAgent, loadAgentLibrary, loadAgentPath, provider, toString
-
-
-
-
Field Detail
-
JNI_ENOMEM
private static final int JNI_ENOMEM
- See Also:
- Constant Field Values
-
ATTACH_ERROR_BADJAR
private static final int ATTACH_ERROR_BADJAR
- See Also:
- Constant Field Values
-
ATTACH_ERROR_NOTONCP
private static final int ATTACH_ERROR_NOTONCP
- See Also:
- Constant Field Values
-
ATTACH_ERROR_STARTFAIL
private static final int ATTACH_ERROR_STARTFAIL
- See Also:
- Constant Field Values
-
defaultAttachTimeout
private static long defaultAttachTimeout
-
attachTimeout
private volatile long attachTimeout
-
-
Constructor Detail
-
HotSpotVirtualMachine
HotSpotVirtualMachine(AttachProvider provider, java.lang.String id)
-
-
Method Detail
-
loadAgentLibrary
private void loadAgentLibrary(java.lang.String agentLibrary, boolean isAbsolute, java.lang.String options) throws AgentLoadException, AgentInitializationException, java.io.IOException
- Throws:
AgentLoadException
AgentInitializationException
java.io.IOException
-
loadAgentLibrary
public void loadAgentLibrary(java.lang.String agentLibrary, java.lang.String options) throws AgentLoadException, AgentInitializationException, java.io.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 theAgent_OnAttach
function as specified in the JVM Tools Interface specification. Note that theAgent_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 theAgent_OnAttach
function in the agent library returns an error then anAgentInitializationException
is thrown. The return value from theAgent_OnAttach
can then be obtained by invoking thereturnValue
method on the exception.- Specified by:
loadAgentLibrary
in classVirtualMachine
- Parameters:
agentLibrary
- The name of the agent library.options
- The options to provide to theAgent_OnAttach
function (can benull
).- Throws:
AgentLoadException
- If the agent library does not exist, or cannot be loaded for another reason.AgentInitializationException
- If theAgent_OnAttach
function returns an errorjava.io.IOException
- If an I/O error occurs- See Also:
AgentInitializationException.returnValue()
-
loadAgentPath
public void loadAgentPath(java.lang.String agentLibrary, java.lang.String options) throws AgentLoadException, AgentInitializationException, java.io.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 theAgent_OnAttach
function as specified in the JVM Tools Interface specification. Note that theAgent_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. UnlikeloadAgentLibrary
, the library name is not expanded in the target virtual machine. If theAgent_OnAttach
function in the agent library returns an error then anAgentInitializationException
is thrown. The return value from theAgent_OnAttach
can then be obtained by invoking thereturnValue
method on the exception.- Specified by:
loadAgentPath
in classVirtualMachine
- Parameters:
agentLibrary
- The full path of the agent library.options
- The options to provide to theAgent_OnAttach
function (can benull
).- Throws:
AgentLoadException
- If the agent library does not exist, or cannot be loaded for another reason.AgentInitializationException
- If theAgent_OnAttach
function returns an errorjava.io.IOException
- If an I/O error occurs- See Also:
AgentInitializationException.returnValue()
-
loadAgent
public void loadAgent(java.lang.String agent, java.lang.String options) throws AgentLoadException, AgentInitializationException, java.io.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 theagentmain
method of the agent class, specified by theAgent-Class
attribute in the JAR manifest, is invoked. This method completes when theagentmain
method completes.- Specified by:
loadAgent
in classVirtualMachine
- Parameters:
agent
- Path to the JAR file containing the agent.options
- The options to provide to the agent'sagentmain
method (can benull
).- Throws:
AgentLoadException
- If the agent does not exist, or cannot be started in the manner specified in thejava.lang.instrument
specification.AgentInitializationException
- If theagentmain
throws an exceptionjava.io.IOException
- If an I/O error occurs
-
getSystemProperties
public java.util.Properties getSystemProperties() throws java.io.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 methodSystem.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 withloadAgent
, orloadAgentLibrary
. For example, thejava.home
oruser.dir
properties might be use to create the path to the agent library or JAR file.- Specified by:
getSystemProperties
in classVirtualMachine
- Returns:
- The system properties
- Throws:
java.io.IOException
- If an I/O error occurs- See Also:
System.getProperties()
,VirtualMachine.loadAgentLibrary(java.lang.String, java.lang.String)
,VirtualMachine.loadAgent(java.lang.String, java.lang.String)
-
getAgentProperties
public java.util.Properties getAgentProperties() throws java.io.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 classVirtualMachine
- Returns:
- The agent properties
- Throws:
java.io.IOException
- If an I/O error occurs
-
localDataDump
public void localDataDump() throws java.io.IOException
- Throws:
java.io.IOException
-
remoteDataDump
public java.io.InputStream remoteDataDump(java.lang.Object... args) throws java.io.IOException
- Throws:
java.io.IOException
-
dumpHeap
public java.io.InputStream dumpHeap(java.lang.Object... args) throws java.io.IOException
- Throws:
java.io.IOException
-
heapHisto
public java.io.InputStream heapHisto(java.lang.Object... args) throws java.io.IOException
- Throws:
java.io.IOException
-
setFlag
public java.io.InputStream setFlag(java.lang.String name, java.lang.String value) throws java.io.IOException
- Throws:
java.io.IOException
-
printFlag
public java.io.InputStream printFlag(java.lang.String name) throws java.io.IOException
- Throws:
java.io.IOException
-
executeJCmd
public java.io.InputStream executeJCmd(java.lang.String command) throws java.io.IOException
- Throws:
java.io.IOException
-
execute
abstract java.io.InputStream execute(java.lang.String cmd, java.lang.Object... args) throws AgentLoadException, java.io.IOException
- Throws:
AgentLoadException
java.io.IOException
-
executeCommand
private java.io.InputStream executeCommand(java.lang.String cmd, java.lang.Object... args) throws java.io.IOException
- Throws:
java.io.IOException
-
readInt
int readInt(java.io.InputStream in) throws java.io.IOException
- Throws:
java.io.IOException
-
attachTimeout
final long attachTimeout()
-
-