Recently, I found there is a java.lang.instrument
package in jdk, which is used by many frameworks to reload classes or profile.
I don't find many articles of using them, is there any resource(book, article, project) to help to understand it?
Instrumentation is the addition of byte-codes to methods for the purpose of gathering data to be utilized by tools.
Defining Java Agents Instrumentation, in the context of software, is a technique used to change an existing application, adding code to it. You can perform instrumentation both manually and automatically. You can also do it both at compiling time and runtime.
For an agent to work, we need to define two methods: premain – will statically load the agent using -javaagent parameter at JVM startup. agentmain – will dynamically load the agent into the JVM using the Java Attach API.
I think this link can help to understand a little the usage of java agents:
hope this will help
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With