views:

182

answers:

2

Hi Everyone,

I'll be working on a project for instrumenting a relatively complex java application, and I'm planning to use java.lang.instrument to hook into the JVM and redefine classes before they're loaded.

What is your take on this package? Is it well supported across JVMs? Does it work well with Hotspot?

Thanks!

A: 

If you want to profile the java application, I would suggest using existing java profilers as this API is definitely still pretty new and has some issues.

Though the following article was written in 2005, the findings pretty much are still relevant

http://www.javalobby.org/java/forums/t19309.html

Fazal
+1  A: 

java.lang.instrument is used by many very popular frameworks and pieces of software, including:

  • AspectJ
  • JRebel
  • JProfiler
  • The java profiling extensions themselves

which leds me to the conclusion that it is save to use. (Maybe not in your in case but that wasn't the question).

I use all the given frameworks while using the HotSpot compiler, and got no problems.

Daniel
Great, thanks for your answer!
Juan Tamayo