- Instrumentation API - provides the ability to add byte-code to existing compiled Java classes
What is a Java Agent
- In general, a java agent is just a specially crafted jar file
- It utilizes the Instrumentation API that the JVM provides to alter existing byte-code that is loaded in a JVM
For an agent to work, we need to define two methods:
- premain – will statically load the agent using
-javaagentparameter at JVM startup - agentmain – will dynamically load the agent into the JVM using the Java Attach API