APIdia Launch Partner
Top Inners Fields Constructors Methods
sun.tools.attach

public abstract Class HotSpotVirtualMachine

extends VirtualMachine
Class Inheritance
Known Direct Subclasses
sun.tools.attach.VirtualMachineImpl
Imports
com.sun.tools.attach.AttachOperationFailedException, .AttachNotSupportedException, .VirtualMachine, .AgentLoadException, .AgentInitializationException, com.sun.tools.attach.spi.AttachProvider, jdk.internal.misc.VM, java.io.BufferedReader, .InputStream, .IOException, .InputStreamReader, java.security.PrivilegedAction, java.util.HashMap, .Map, .Properties, java.util.stream.Collectors, java.nio.charset.StandardCharsets

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
protected static class
pack-priv abstract static class

Field Summary

Modifier and TypeField and Description
private static final boolean
private static final boolean
private static final int
private static final int
private static final int
private static final int
private volatile long
private static final long
private static long
private static final int
private static final String
private final boolean
protected static final int
protected static final int

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
pack-priv long
private static boolean
protected static void
checkNulls(Object... args)

private int
public InputStream
dumpHeap(Object... args)

private String
pack-priv abstract InputStream
execute(String cmd, Object... args)

public InputStream
public InputStream
public Properties
getAgentProperties()

Implements abstract com.sun.tools.attach.VirtualMachine.getAgentProperties.

Returns the current agent properties in the target virtual machine.

protected HotSpotVirtualMachine.OperationProperties
public Properties
getSystemProperties()

Implements abstract com.sun.tools.attach.VirtualMachine.getSystemProperties.

Returns the current system properties in the target virtual machine.

public InputStream
heapHisto(Object... args)

protected boolean
protected boolean
public void
loadAgent(String agent, String options)

Implements abstract com.sun.tools.attach.VirtualMachine.loadAgent.

Loads an agent.

private void
loadAgentLibrary(String agentLibrary, boolean isAbsolute, String options)

public void
loadAgentLibrary(String agentLibrary, String options)

Implements abstract com.sun.tools.attach.VirtualMachine.loadAgentLibrary.

Loads an agent library.

public void
loadAgentPath(String agentLibrary, String options)

Implements abstract com.sun.tools.attach.VirtualMachine.loadAgentPath.

Load a native agent library by full pathname.

public void
private static long
pid()

public InputStream
pack-priv void
pack-priv int
pack-priv String
public InputStream
public InputStream
setFlag(String name, String value)

public String
startLocalManagementAgent()

Implements abstract com.sun.tools.attach.VirtualMachine.startLocalManagementAgent.

Starts the local JMX management agent in the target virtual machine.

public void
startManagementAgent(Properties agentProperties)

Implements abstract com.sun.tools.attach.VirtualMachine.startManagementAgent.

Starts the JMX management agent in the target virtual machine.

private static String
protected void
private void
Inherited from com.sun.tools.attach.VirtualMachine:
attachattachdetachequalshashCodeidlistloadAgentloadAgentLibraryloadAgentPathprovidertoString

Field Detail

ALLOW_ATTACH_SELFback to summary
private static final boolean ALLOW_ATTACH_SELF
ALLOW_STREAMING_OUTPUTback to summary
private static final boolean ALLOW_STREAMING_OUTPUT
ATTACH_ERROR_BADJARback to summary
private static final int ATTACH_ERROR_BADJAR
ATTACH_ERROR_BADVERSIONback to summary
private static final int ATTACH_ERROR_BADVERSION
ATTACH_ERROR_NOTONCPback to summary
private static final int ATTACH_ERROR_NOTONCP
ATTACH_ERROR_STARTFAILback to summary
private static final int ATTACH_ERROR_STARTFAIL
attachTimeoutback to summary
private volatile long attachTimeout
CURRENT_PIDback to summary
private static final long CURRENT_PID
defaultAttachTimeoutback to summary
private static long defaultAttachTimeout
JNI_ENOMEMback to summary
private static final int JNI_ENOMEM
MANAGEMENT_PREFIXback to summary
private static final String MANAGEMENT_PREFIX
selfAttachback to summary
private final boolean selfAttach
VERSION_1back to summary
protected static final int VERSION_1
VERSION_2back to summary
protected static final int VERSION_2

Constructor Detail

HotSpotVirtualMachineback to summary
pack-priv HotSpotVirtualMachine(AttachProvider provider, String id) throws AttachNotSupportedException, IOException

Method Detail

attachTimeoutback to summary
pack-priv long attachTimeout()
checkedKeyNameback to summary
private static boolean checkedKeyName(Object key)
checkNullsback to summary
protected static void checkNulls(Object... args)
dataSizeback to summary
private int dataSize(Object obj)
dumpHeapback to summary
public InputStream dumpHeap(Object... args) throws IOException
escapeback to summary
private String escape(Object arg)
executeback to summary
pack-priv abstract InputStream execute(String cmd, Object... args) throws AgentLoadException, IOException
executeCommandback to summary
public InputStream executeCommand(String cmd, Object... args) throws IOException
executeJCmdback to summary
public InputStream executeJCmd(String command) throws IOException
getAgentPropertiesback to summary
public Properties getAgentProperties() throws IOException

Implements abstract com.sun.tools.attach.VirtualMachine.getAgentProperties.

Doc from com.sun.tools.attach.VirtualMachine.getAgentProperties.

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.

Exceptions
IOException:
If an I/O error occurs, a communication error for example, that cannot be identified as an error to indicate that the operation failed in the target VM.
getDefaultPropsback to summary
protected HotSpotVirtualMachine.OperationProperties getDefaultProps() throws IOException
getSystemPropertiesback to summary
public Properties getSystemProperties() throws IOException

Implements abstract com.sun.tools.attach.VirtualMachine.getSystemProperties.

Doc from com.sun.tools.attach.VirtualMachine.getSystemProperties.

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.

Exceptions
IOException:
If an I/O error occurs, a communication error for example, that cannot be identified as an error to indicate that the operation failed in the target VM.
heapHistoback to summary
public InputStream heapHisto(Object... args) throws IOException
isAPIv2Enabledback to summary
protected boolean isAPIv2Enabled()
isStreamingEnabledback to summary
protected boolean isStreamingEnabled()
loadAgentback to summary
public void loadAgent(String agent, String options) throws AgentLoadException, AgentInitializationException, IOException

Implements abstract com.sun.tools.attach.VirtualMachine.loadAgent.

Doc from com.sun.tools.attach.VirtualMachine.loadAgent.

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.

Exceptions
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
loadAgentLibraryback to summary
private void loadAgentLibrary(String agentLibrary, boolean isAbsolute, String options) throws AgentLoadException, AgentInitializationException, IOException
loadAgentLibraryback to summary
public void loadAgentLibrary(String agentLibrary, String options) throws AgentLoadException, AgentInitializationException, IOException

Implements abstract com.sun.tools.attach.VirtualMachine.loadAgentLibrary.

Doc from com.sun.tools.attach.VirtualMachine.loadAgentLibrary.

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. Alternatively, it may be statically linked into the VM. This method causes the given agent library to be loaded into the target VM (if not already loaded or if not statically linked into the VM). It then causes the target VM to invoke the Agent_OnAttach function or, for a statically linked agent named 'L', the Agent_OnAttach_L function as specified in the JVM Tools Interface specification. Note that the Agent_OnAttach[_L] 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 L might be expanded to libL.so, and located using the search path specified by the LD_LIBRARY_PATH environment variable. If the agent named 'L' is statically linked into the VM then the VM must export a function named Agent_OnAttach_L.

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

Exceptions
AgentLoadException:
If the agent library does not exist, the agent library is not statically linked with the VM, or the agent library cannot be loaded for another reason.
AgentInitializationException:
If the Agent_OnAttach[_L] function returns an error.
IOException:
If an I/O error occurs
loadAgentPathback to summary
public void loadAgentPath(String agentLibrary, String options) throws AgentLoadException, AgentInitializationException, IOException

Implements abstract com.sun.tools.attach.VirtualMachine.loadAgentPath.

Doc from com.sun.tools.attach.VirtualMachine.loadAgentPath.

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. Alternatively, the native library specified by the agentPath parameter may be statically linked with the VM. The parsing of the agentPath parameter into a statically linked library name is done in a platform specific manner in the VM. For example, in UNIX, an agentPath parameter of /a/b/libL.so would name a library 'L'. See the JVM TI Specification for more details. This method causes the given agent library to be loaded into the target VM (if not already loaded or if not statically linked into the VM). It then causes the target VM to invoke the Agent_OnAttach function or, for a statically linked agent named 'L', the Agent_OnAttach_L function as specified in the JVM Tools Interface specification. Note that the Agent_OnAttach[_L] 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[_L] function in the agent library returns an error then an com.sun.tools.attach.AgentInitializationException is thrown. The return value from the Agent_OnAttach[_L] can then be obtained by invoking the returnValue method on the exception.

Exceptions
AgentLoadException:
If the agent library does not exist, the agent library is not statically linked with the VM, or the agent library cannot be loaded for another reason.
AgentInitializationException:
If the Agent_OnAttach[_L] function returns an error.
IOException:
If an I/O error occurs
localDataDumpback to summary
public void localDataDump() throws IOException
pidback to summary
private static long pid()
Annotations
@SuppressWarnings:removal
printFlagback to summary
public InputStream printFlag(String name) throws IOException
processCompletionStatusback to summary
pack-priv void processCompletionStatus(IOException ioe, String cmd, InputStream sis) throws AgentLoadException, IOException
readIntback to summary
pack-priv int readInt(InputStream in) throws IOException
readMessageback to summary
pack-priv String readMessage(InputStream in) throws IOException
remoteDataDumpback to summary
public InputStream remoteDataDump(Object... args) throws IOException
setFlagback to summary
public InputStream setFlag(String name, String value) throws IOException
startLocalManagementAgentback to summary
public String startLocalManagementAgent() throws IOException

Implements abstract com.sun.tools.attach.VirtualMachine.startLocalManagementAgent.

Doc from com.sun.tools.attach.VirtualMachine.startLocalManagementAgent.

Starts the local JMX management agent in the target virtual machine.

See the online documentation for Monitoring and Management Using JMX Technology for further details.

Annotations
@Override
Exceptions
IOException:
If an I/O error occurs, a communication error for example, that cannot be identified as an error to indicate that the operation failed in the target VM.
startManagementAgentback to summary
public void startManagementAgent(Properties agentProperties) throws IOException

Implements abstract com.sun.tools.attach.VirtualMachine.startManagementAgent.

Doc from com.sun.tools.attach.VirtualMachine.startManagementAgent.

Starts the JMX management agent in the target virtual machine.

The configuration properties are the same as those specified on the command line when starting the JMX management agent. In the same way as on the command line, you need to specify at least the com.sun.management.jmxremote.port property.

See the online documentation for Monitoring and Management Using JMX Technology for further details.

Annotations
@Override
Exceptions
IOException:
If an I/O error occurs, a communication error for example, that cannot be identified as an error to indicate that the operation failed in the target VM.
stripKeyNameback to summary
private static String stripKeyName(Object key)
writeCommandback to summary
protected void writeCommand(HotSpotVirtualMachine.AttachOutputStream writer, HotSpotVirtualMachine.OperationProperties props, String cmd, Object... args) throws IOException
writeStringback to summary
private void writeString(HotSpotVirtualMachine.AttachOutputStream writer, Object obj) throws IOException
sun.tools.attach back to summary

public Interface HotSpotVirtualMachine.AttachOutputStream

Known Direct Implementers
sun.tools.attach.VirtualMachineImpl.SocketOutputStream

Method Summary

Modifier and TypeMethod and Description
public void
write(byte[] buffer, int offset, int length)

Method Detail

writeback to summary
public void write(byte[] buffer, int offset, int length) throws IOException
sun.tools.attach back to summary

protected Class HotSpotVirtualMachine.OperationProperties

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
private Map<String, String>
public static final String
private int

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
pack-priv String
pack-priv void
setOption(String name, String value)

pack-priv int
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

optionsback to summary
private Map<String, String> options
STREAMINGback to summary
public static final String STREAMING
verback to summary
private int ver

Constructor Detail

OperationPropertiesback to summary
pack-priv OperationProperties(int ver)

Method Detail

optionsback to summary
pack-priv String options()
setOptionback to summary
pack-priv void setOption(String name, String value)
versionback to summary
pack-priv int version()
sun.tools.attach back to summary

pack-priv abstract Class HotSpotVirtualMachine.SocketInputStream

extends InputStream
Class Inheritance
Known Direct Subclasses
sun.tools.attach.VirtualMachineImpl.SocketInputStreamImpl

Field Summary

Modifier and TypeField and Description
private long

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected abstract void
close(long fd)

public synchronized void
close()

Overrides java.io.InputStream.close.

Implements java.io.Closeable.close.

Closes this input stream and releases any system resources associated with the stream.

protected abstract int
read(long fd, byte[] bs, int off, int len)

public synchronized int
read()

Implements abstract java.io.InputStream.read.

Reads the next byte of data from the input stream.

public synchronized int
read(byte[] bs, int off, int len)

Overrides java.io.InputStream.read.

Reads up to len bytes of data from the input stream into an array of bytes.

Inherited from java.io.InputStream:
availablemarkmarkSupportednullInputStreamreadreadAllBytesreadNBytesreadNBytesresetskipskipNBytestransferTo

Field Detail

fdback to summary
private long fd

Constructor Detail

SocketInputStreamback to summary
public SocketInputStream(long fd)

Method Detail

closeback to summary
protected abstract void close(long fd) throws IOException
closeback to summary
public synchronized void close() throws IOException

Overrides java.io.InputStream.close.

Implements java.io.Closeable.close.

Doc from java.io.InputStream.close.

Closes this input stream and releases any system resources associated with the stream.

Exceptions
IOException:
if an I/O error occurs.
readback to summary
protected abstract int read(long fd, byte[] bs, int off, int len) throws IOException
readback to summary
public synchronized int read() throws IOException

Implements abstract java.io.InputStream.read.

Doc from java.io.InputStream.read.

Reads the next byte of data from the input stream. The value byte is returned as an int in the range 0 to 255. If no byte is available because the end of the stream has been reached, the value -1 is returned. This method blocks until input data is available, the end of the stream is detected, or an exception is thrown.

Exceptions
IOException:
if an I/O error occurs.
readback to summary
public synchronized int read(byte[] bs, int off, int len) throws IOException

Overrides java.io.InputStream.read.

Doc from java.io.InputStream.read.

Reads up to len bytes of data from the input stream into an array of bytes. An attempt is made to read as many as len bytes, but a smaller number may be read. The number of bytes actually read is returned as an integer.

This method blocks until input data is available, end of file is detected, or an exception is thrown.

If len is zero, then no bytes are read and 0 is returned; otherwise, there is an attempt to read at least one byte. If no byte is available because the stream is at end of file, the value -1 is returned; otherwise, at least one byte is read and stored into b.

The first byte read is stored into element b[off], the next one into b[off+1], and so on. The number of bytes read is, at most, equal to len. Let k be the number of bytes actually read; these bytes will be stored in elements b[off] through b[off+k-1], leaving elements b[off+k] through b[off+len-1] unaffected.

In every case, elements b[0] through b[off-1] and elements b[off+len] through b[b.length-1] are unaffected.

Exceptions
IOException:
If the first byte cannot be read for any reason other than end of file, or if the input stream has been closed, or if some other I/O error occurs.