Interface VirtualMachine
- All Known Implementing Classes:
VirtualMachine.AbstractBase, VirtualMachine.ForHotSpot, VirtualMachine.ForOpenJ9
public interface VirtualMachine
An implementation for attachment on a virtual machine. This interface mimics the tooling API's virtual
machine interface to allow for similar usage by ByteBuddyAgent where all calls are made via
reflection such that this structural typing suffices for interoperability.
Note: Implementations are required to declare a static method attach(String) returning an
instance of a class that declares the methods defined by VirtualMachine.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classAn abstract base implementation for a virtual machine.static classA virtual machine attachment implementation for a HotSpot VM or any compatible JVM.static classA virtual machine attachment implementation for OpenJ9 or any compatible JVM.static enumA resolver for the current VM's virtual machine attachment emulation. -
Method Summary
Modifier and TypeMethodDescriptionvoiddetach()Detaches this virtual machine representation.Loads the target VMs agent properties.Loads the target VMs system properties.voidLoads an agent into the represented virtual machine.voidLoads an agent into the represented virtual machine.voidloadAgentLibrary(String library) Loads a native agent library into the represented virtual machine.voidloadAgentLibrary(String library, String argument) Loads a native agent library into the represented virtual machine.voidloadAgentPath(String path) Loads a native agent 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.
-
Method Details
-
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.
-
loadAgent
Loads an agent into the represented virtual machine.- Parameters:
jarFile- The jar file to attach.- 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.- 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.- 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.
-
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.
-