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 interface
VirtualMachine.ForHotSpot.Connection
Represents a connection to a virtual machine.-
Nested classes/interfaces inherited from interface net.bytebuddy.agent.VirtualMachine
VirtualMachine.AbstractBase, VirtualMachine.ForHotSpot, VirtualMachine.ForOpenJ9, VirtualMachine.Resolver
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
ForHotSpot(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 VirtualMachine
attach(String processId)
Attaches to the supplied process id using the default JNA implementation.static VirtualMachine
attach(String processId, VirtualMachine.ForHotSpot.Connection.Factory connectionFactory)
Attaches to the supplied process id using the supplied connection factory.void
detach()
Detaches this virtual machine representation.Properties
getAgentProperties()
Loads the target VMs agent properties.Properties
getSystemProperties()
Loads the target VMs system properties.protected void
load(String file, boolean absolute, String argument)
Loads an agent by the given command.void
loadAgent(String jarFile, String argument)
Loads an agent into the represented virtual machine.void
loadAgentLibrary(String library, String argument)
Loads a native agent library into the represented virtual machine.void
loadAgentPath(String path, String argument)
Loads a native agent into the represented virtual machine.String
startLocalManagementAgent()
Starts a local management agent.void
startManagementAgent(Properties properties)
Starts a JMX management agent.-
Methods inherited from class net.bytebuddy.agent.VirtualMachine.AbstractBase
loadAgent, loadAgentLibrary, loadAgentPath
-
-
-
-
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(String processId) throws IOException
Attaches to the supplied process id using the default JNA implementation.- Parameters:
processId
- The process id.- Returns:
- A suitable virtual machine implementation.
- Throws:
IOException
- If an IO exception occurs during establishing the connection.
-
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.
-
getSystemProperties
public Properties getSystemProperties() throws IOException
Loads the target VMs system properties.- Returns:
- The target VM properties.
- Throws:
IOException
- If an I/O exception occurs.
-
getAgentProperties
public Properties getAgentProperties() throws IOException
Loads the target VMs agent properties.- Returns:
- The target VM properties.
- Throws:
IOException
- If an I/O exception occurs.
-
loadAgent
public void loadAgent(String jarFile, String argument) throws IOException
Loads an agent into the represented virtual machine.- Parameters:
jarFile
- The jar file to attach.argument
- The argument to provide ornull
if no argument should be provided.- Throws:
IOException
- If an I/O exception occurs.
-
loadAgentPath
public void loadAgentPath(String path, String argument) throws IOException
Loads a native agent into the represented virtual machine.- Parameters:
path
- The agent path.argument
- The argument to provide ornull
if no argument should be provided.- Throws:
IOException
- If an I/O exception occurs.
-
loadAgentLibrary
public void loadAgentLibrary(String library, String argument) throws IOException
Loads a native agent library into the represented virtual machine.- Parameters:
library
- The agent library.argument
- The argument to provide ornull
if no argument should be provided.- Throws:
IOException
- If an I/O exception occurs.
-
load
protected void load(String file, boolean absolute, String argument) throws IOException
Loads an agent by the given command.- Parameters:
file
- The Java agent or library to be loaded.absolute
-true
if the agent location is absolute.argument
- The argument to the agent ornull
if no argument is given.- Throws:
IOException
- If an I/O exception occurs.
-
startManagementAgent
public void startManagementAgent(Properties properties) throws IOException
Starts a JMX management agent.- Parameters:
properties
- The properties to transfer to the JMX agent.- Throws:
IOException
- If an I/O error occurs.
-
startLocalManagementAgent
public String startLocalManagementAgent() throws IOException
Starts a local management agent.- Returns:
- The local connector address.
- Throws:
IOException
- If an I/O error occurs.
-
detach
public void detach() throws IOException
Detaches this virtual machine representation.- Throws:
IOException
- If an I/O exception occurs.
-
-