Package net.bytebuddy.agent
Class VirtualMachine.ForHotSpot
- java.lang.Object
-
- net.bytebuddy.agent.VirtualMachine.AbstractBase
-
- net.bytebuddy.agent.VirtualMachine.ForHotSpot
-
- All Implemented Interfaces:
VirtualMachine
- Enclosing interface:
- VirtualMachine
public static class VirtualMachine.ForHotSpot extends VirtualMachine.AbstractBase
A virtual machine attachment implementation for a HotSpot VM or any compatible JVM.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceVirtualMachine.ForHotSpot.ConnectionRepresents a connection to a virtual machine.-
Nested classes/interfaces inherited from interface net.bytebuddy.agent.VirtualMachine
VirtualMachine.AbstractBase, VirtualMachine.ForHotSpot, VirtualMachine.ForOpenJ9, VirtualMachine.Resolver
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.StringARGUMENT_DELIMITERA delimiter to be used for attachment.private VirtualMachine.ForHotSpot.ConnectionconnectionThe virtual machine connection.private static java.lang.StringINSTRUMENT_COMMANDTheinstrumentcommand.private static java.lang.StringLOAD_COMMANDTheloadcommand.private static java.lang.StringPROTOCOL_VERSIONThe protocol version to use for communication.
-
Constructor Summary
Constructors Modifier Constructor Description protectedForHotSpot(VirtualMachine.ForHotSpot.Connection connection)Creates a new virtual machine connection for HotSpot.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static VirtualMachineattach(java.lang.String processId)Attaches to the supplied process id using the default JNA implementation.static VirtualMachineattach(java.lang.String processId, VirtualMachine.ForHotSpot.Connection.Factory connectionFactory)Attaches to the supplied process id using the supplied connection factory.private static voidcheckHeader(VirtualMachine.ForHotSpot.Connection.Response response)Checks the header of a response.voiddetach()Detaches this virtual machine representation.java.util.PropertiesgetAgentProperties()Loads the target VMs agent properties.private java.util.PropertiesgetProperties(java.lang.String command)Loads properties of the target VM.java.util.PropertiesgetSystemProperties()Loads the target VMs system properties.protected voidload(java.lang.String file, boolean absolute, java.lang.String argument)Loads an agent by the given command.voidloadAgent(java.lang.String jarFile, java.lang.String argument)Loads an agent into the represented virtual machine.voidloadAgentLibrary(java.lang.String library, java.lang.String argument)Loads a native agent library into the represented virtual machine.voidloadAgentPath(java.lang.String path, java.lang.String argument)Loads a native agent into the represented virtual machine.java.lang.StringstartLocalManagementAgent()Starts a local management agent.voidstartManagementAgent(java.util.Properties properties)Starts a JMX management agent.-
Methods inherited from class net.bytebuddy.agent.VirtualMachine.AbstractBase
loadAgent, loadAgentLibrary, loadAgentPath
-
-
-
-
Field Detail
-
PROTOCOL_VERSION
private static final java.lang.String PROTOCOL_VERSION
The protocol version to use for communication.- See Also:
- Constant Field Values
-
LOAD_COMMAND
private static final java.lang.String LOAD_COMMAND
Theloadcommand.- See Also:
- Constant Field Values
-
INSTRUMENT_COMMAND
private static final java.lang.String INSTRUMENT_COMMAND
Theinstrumentcommand.- See Also:
- Constant Field Values
-
ARGUMENT_DELIMITER
private static final java.lang.String ARGUMENT_DELIMITER
A delimiter to be used for attachment.- See Also:
- Constant Field Values
-
connection
private final VirtualMachine.ForHotSpot.Connection connection
The virtual machine connection.
-
-
Constructor Detail
-
ForHotSpot
protected ForHotSpot(VirtualMachine.ForHotSpot.Connection connection)
Creates a new virtual machine connection for HotSpot.- Parameters:
connection- The virtual machine connection.
-
-
Method Detail
-
attach
public static VirtualMachine attach(java.lang.String processId) throws java.io.IOException
Attaches to the supplied process id using the default JNA implementation.- Parameters:
processId- The process id.- Returns:
- A suitable virtual machine implementation.
- Throws:
java.io.IOException- If an IO exception occurs during establishing the connection.
-
attach
public static VirtualMachine attach(java.lang.String processId, VirtualMachine.ForHotSpot.Connection.Factory connectionFactory) throws java.io.IOException
Attaches to the supplied process id using the supplied connection factory.- Parameters:
processId- The process id.connectionFactory- The connection factory to use.- Returns:
- A suitable virtual machine implementation.
- Throws:
java.io.IOException- If an IO exception occurs during establishing the connection.
-
checkHeader
private static void checkHeader(VirtualMachine.ForHotSpot.Connection.Response response) throws java.io.IOException
Checks the header of a response.- Parameters:
response- The response to check the header for.- Throws:
java.io.IOException- If an I/O exception occurs.
-
getSystemProperties
public java.util.Properties getSystemProperties() throws java.io.IOExceptionLoads the target VMs system properties.- Returns:
- The target VM properties.
- Throws:
java.io.IOException- If an I/O exception occurs.
-
getAgentProperties
public java.util.Properties getAgentProperties() throws java.io.IOExceptionLoads the target VMs agent properties.- Returns:
- The target VM properties.
- Throws:
java.io.IOException- If an I/O exception occurs.
-
getProperties
private java.util.Properties getProperties(java.lang.String command) throws java.io.IOExceptionLoads properties of the target VM.- Parameters:
command- The command for fetching properties.- Returns:
- The read properties.
- Throws:
java.io.IOException- If an I/O exception occurs.
-
loadAgent
public void loadAgent(java.lang.String jarFile, @MaybeNull java.lang.String argument) throws java.io.IOExceptionLoads an agent into the represented virtual machine.- Parameters:
jarFile- The jar file to attach.argument- The argument to provide ornullif no argument should be provided.- Throws:
java.io.IOException- If an I/O exception occurs.
-
loadAgentPath
public void loadAgentPath(java.lang.String path, @MaybeNull java.lang.String argument) throws java.io.IOExceptionLoads a native agent into the represented virtual machine.- Parameters:
path- The agent path.argument- The argument to provide ornullif no argument should be provided.- Throws:
java.io.IOException- If an I/O exception occurs.
-
loadAgentLibrary
public void loadAgentLibrary(java.lang.String library, @MaybeNull java.lang.String argument) throws java.io.IOExceptionLoads a native agent library into the represented virtual machine.- Parameters:
library- The agent library.argument- The argument to provide ornullif no argument should be provided.- Throws:
java.io.IOException- If an I/O exception occurs.
-
load
protected void load(java.lang.String file, boolean absolute, @MaybeNull java.lang.String argument) throws java.io.IOExceptionLoads an agent by the given command.- Parameters:
file- The Java agent or library to be loaded.absolute-trueif the agent location is absolute.argument- The argument to the agent ornullif no argument is given.- Throws:
java.io.IOException- If an I/O exception occurs.
-
startManagementAgent
public void startManagementAgent(java.util.Properties properties) throws java.io.IOExceptionStarts 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
public java.lang.String startLocalManagementAgent() throws java.io.IOExceptionStarts a local management agent.- Returns:
- The local connector address.
- Throws:
java.io.IOException- If an I/O error occurs.
-
detach
public void detach() throws java.io.IOExceptionDetaches this virtual machine representation.- Throws:
java.io.IOException- If an I/O exception occurs.
-
-