Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to understand and learn `instrument` package of java?

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?

like image 834
Freewind Avatar asked Aug 23 '11 07:08

Freewind


People also ask

What is instrumentation in Java?

Instrumentation is the addition of byte-codes to methods for the purpose of gathering data to be utilized by tools.

How does Java instrumentation work?

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.

What is Premain method in Java?

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.


1 Answers

I think this link can help to understand a little the usage of java agents:

  • Not So Secret Java Agent (1)
  • Not So Secret Java Agent (2)
  • Not So Secret Java Agent (3)
  • Not So Secret Java Agent (4)

hope this will help

like image 60
Mark Bramnik Avatar answered Oct 26 '22 01:10

Mark Bramnik