Class HotSpotVirtualMachine
java.lang.Object
com.sun.tools.attach.VirtualMachine
sun.tools.attach.HotSpotVirtualMachine
- Direct Known Subclasses:
BsdVirtualMachine, LinuxVirtualMachine, SolarisVirtualMachine, WindowsVirtualMachine
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final intprivate static final intprivate static final intprivate longprivate static longprivate static final int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) final long(package private) abstract InputStreamprivate InputStreamexecuteCommand(String cmd, Object... args) executeJCmd(String command) Returns the current agent properties in the target virtual machine.Returns the current system properties in the target virtual machine.voidLoads an agent.private voidloadAgentLibrary(String agentLibrary, boolean isAbsolute, String options) voidloadAgentLibrary(String agentLibrary, String options) Loads an agent library.voidloadAgentPath(String agentLibrary, String options) Load a native agent library by full pathname.void(package private) intreadInt(InputStream in) remoteDataDump(Object... args) Methods inherited from class VirtualMachine
attach, attach, detach, equals, hashCode, id, list, loadAgent, loadAgentLibrary, loadAgentPath, provider, toString
-
Field Details
-
JNI_ENOMEM
private static final int JNI_ENOMEM- See Also:
-
ATTACH_ERROR_BADJAR
private static final int ATTACH_ERROR_BADJAR- See Also:
-
ATTACH_ERROR_NOTONCP
private static final int ATTACH_ERROR_NOTONCP- See Also:
-
ATTACH_ERROR_STARTFAIL
private static final int ATTACH_ERROR_STARTFAIL- See Also:
-
defaultAttachTimeout
private static long defaultAttachTimeout -
attachTimeout
private volatile long attachTimeout
-
-
Constructor Details
-
HotSpotVirtualMachine
HotSpotVirtualMachine(AttachProvider provider, String id)
-
-
Method Details
-
loadAgentLibrary
private void loadAgentLibrary(String agentLibrary, boolean isAbsolute, String options) throws AgentLoadException, AgentInitializationException, IOException -
loadAgentLibrary
public void loadAgentLibrary(String agentLibrary, String options) throws AgentLoadException, AgentInitializationException, IOException Description copied from class:VirtualMachineLoads 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_OnAttachfunction as specified in the JVM Tools Interface specification. Note that theAgent_OnAttachfunction 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_OnAttachfunction in the agent library returns an error then anAgentInitializationExceptionis thrown. The return value from theAgent_OnAttachcan then be obtained by invoking thereturnValuemethod on the exception.- Specified by:
loadAgentLibraryin classVirtualMachine- Parameters:
agentLibrary- The name of the agent library.options- The options to provide to theAgent_OnAttachfunction (can benull).- Throws:
AgentLoadException- If the agent library does not exist, or cannot be loaded for another reason.AgentInitializationException- If theAgent_OnAttachfunction returns an errorIOException- If an I/O error occurs- See Also:
-
loadAgentPath
public void loadAgentPath(String agentLibrary, String options) throws AgentLoadException, AgentInitializationException, IOException Description copied from class:VirtualMachineLoad 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_OnAttachfunction as specified in the JVM Tools Interface specification. Note that theAgent_OnAttachfunction 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_OnAttachfunction in the agent library returns an error then anAgentInitializationExceptionis thrown. The return value from theAgent_OnAttachcan then be obtained by invoking thereturnValuemethod on the exception.- Specified by:
loadAgentPathin classVirtualMachine- Parameters:
agentLibrary- The full path of the agent library.options- The options to provide to theAgent_OnAttachfunction (can benull).- Throws:
AgentLoadException- If the agent library does not exist, or cannot be loaded for another reason.AgentInitializationException- If theAgent_OnAttachfunction returns an errorIOException- If an I/O error occurs- See Also:
-
loadAgent
public void loadAgent(String agent, String options) throws AgentLoadException, AgentInitializationException, IOException Description copied from class:VirtualMachineLoads 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.instrumentspecification. That is, the specified JAR file is added to the system class path (of the target virtual machine), and theagentmainmethod of the agent class, specified by theAgent-Classattribute in the JAR manifest, is invoked. This method completes when theagentmainmethod completes.- Specified by:
loadAgentin classVirtualMachine- Parameters:
agent- Path to the JAR file containing the agent.options- The options to provide to the agent'sagentmainmethod (can benull).- Throws:
AgentLoadException- If the agent does not exist, or cannot be started in the manner specified in thejava.lang.instrumentspecification.AgentInitializationException- If theagentmainthrows an exceptionIOException- If an I/O error occurs
-
getSystemProperties
Description copied from class:VirtualMachineReturns 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.getPropertiesin 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.homeoruser.dirproperties might be use to create the path to the agent library or JAR file.- Specified by:
getSystemPropertiesin classVirtualMachine- Returns:
- The system properties
- Throws:
IOException- If an I/O error occurs- See Also:
-
getAgentProperties
Description copied from class:VirtualMachineReturns 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:
getAgentPropertiesin classVirtualMachine- Returns:
- The agent properties
- Throws:
IOException- If an I/O error occurs
-
localDataDump
- Throws:
IOException
-
remoteDataDump
- Throws:
IOException
-
dumpHeap
- Throws:
IOException
-
heapHisto
- Throws:
IOException
-
setFlag
- Throws:
IOException
-
printFlag
- Throws:
IOException
-
executeJCmd
- Throws:
IOException
-
execute
- Throws:
AgentLoadExceptionIOException
-
executeCommand
- Throws:
IOException
-
readInt
- Throws:
IOException
-
attachTimeout
final long attachTimeout()
-