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
A virtual machine attachment implementation for a HotSpot VM or any compatible JVM.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceRepresents a connection to a virtual machine.Nested classes/interfaces inherited from interface net.bytebuddy.agent.VirtualMachine
VirtualMachine.AbstractBase, VirtualMachine.ForHotSpot, VirtualMachine.Resolver -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final StringA delimiter to be used for attachment.private final VirtualMachine.ForHotSpot.ConnectionThe virtual machine connection.private static final StringTheinstrumentcommand.private static final StringTheloadcommand.private static final StringThe protocol version to use for communication. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedForHotSpot(VirtualMachine.ForHotSpot.Connection connection) Creates a new virtual machine connection for HotSpot. -
Method Summary
Modifier and TypeMethodDescriptionstatic VirtualMachineattach(String processId, VirtualMachine.ForHotSpot.Connection.Factory connectionFactory) Attaches to the supplied process id using the supplied connection factory.private static voidChecks the header of a response.voiddetach()Detaches this virtual machine representation.Loads the target VMs agent properties.private PropertiesgetProperties(String command) Loads properties of the target VM.Loads the target VMs system properties.protected voidLoads an agent by the given command.voidLoads an agent into the represented virtual machine.voidloadAgentLibrary(String library, String argument) Loads a native agent library into the represented virtual machine.voidloadAgentPath(String path, String argument) Loads a native agent into the represented virtual machine.Starts a local management agent.voidstartManagementAgent(Properties properties) Starts a JMX management agent.Methods inherited from class net.bytebuddy.agent.VirtualMachine.AbstractBase
loadAgent, loadAgentLibrary, loadAgentPath
-
Field Details
-
PROTOCOL_VERSION
The protocol version to use for communication.- See Also:
-
LOAD_COMMAND
Theloadcommand.- See Also:
-
INSTRUMENT_COMMAND
Theinstrumentcommand.- See Also:
-
ARGUMENT_DELIMITER
A delimiter to be used for attachment.- See Also:
-
connection
The virtual machine connection.
-
-
Constructor Details
-
ForHotSpot
Creates a new virtual machine connection for HotSpot.- Parameters:
connection- The virtual machine connection.
-
-
Method Details
-
attach
public static VirtualMachine attach(String processId, VirtualMachine.ForHotSpot.Connection.Factory connectionFactory) throws 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:
IOException- If an IO exception occurs during establishing the connection.
-
checkHeader
private static void checkHeader(VirtualMachine.ForHotSpot.Connection.Response response) throws IOException Checks the header of a response.- Parameters:
response- The response to check the header for.- Throws:
IOException- If an I/O exception occurs.
-
getSystemProperties
Loads the target VMs system properties.- Returns:
- The target VM properties.
- Throws:
IOException- If an I/O exception occurs.
-
getAgentProperties
Loads the target VMs agent properties.- Returns:
- The target VM properties.
- Throws:
IOException- If an I/O exception occurs.
-
getProperties
Loads properties of the target VM.- Parameters:
command- The command for fetching properties.- Returns:
- The read properties.
- Throws:
IOException- If an I/O exception occurs.
-
loadAgent
Loads 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:
IOException- If an I/O exception occurs.
-
loadAgentPath
Loads 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:
IOException- If an I/O exception occurs.
-
loadAgentLibrary
Loads 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:
IOException- If an I/O exception occurs.
-
load
Loads 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:
IOException- If an I/O exception occurs.
-
startManagementAgent
Starts a JMX management agent.- Parameters:
properties- The properties to transfer to the JMX agent.- Throws:
IOException- If an I/O error occurs.
-
startLocalManagementAgent
Starts a local management agent.- Returns:
- The local connector address.
- Throws:
IOException- If an I/O error occurs.
-
detach
Detaches this virtual machine representation.- Throws:
IOException- If an I/O exception occurs.
-