How mature is java.lang.instrument?
I'll be working on a project for instrumenting a relatively complex java applica开发者_运维百科tion, 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!
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.
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
精彩评论