Skip to content

Instantly share code, notes, and snippets.

View achievec's full-sized avatar
😬
surfing

aloha_world_ achievec

😬
surfing
View GitHub Profile
@achievec
achievec / AgentRunner.java
Last active September 14, 2021 06:10 — forked from xnike/AgentRunner.java
Simple snippet to show how to attach javaagent to running JVM process
import com.sun.tools.attach.VirtualMachine;
import com.sun.tools.attach.VirtualMachineDescriptor;
public class AgentRunner {
/*
* This class shows how to attach hotswap-agent.jar to a running JVM process and overload classes using "extraClasspath=" property via Hotswapper plugin.
*
* Lets assume that:
* args[0] contains pid of running JVM process or a runner class name we want to attach agent to