Search code examples
javatracejvm-hotspotdtracejvmti

How to trace java application in "dtrace style"?


I have task of tracing some java application with dynamic probes (like dtrace or systemtap). Of course, it should be done without application restarts or recompiles. It should allow dynamic setting of interceptors on methods calls and internal JVM events. In solaris it could be done by dtrace, but not in other systems. How I can resolve this task?


Solution

  • On linux (at least on fedora and red hat) you can do it with systemtap, see this link for the explanation. It uses byteman to trace java applications. Though you can not use systemtap on other platforms than linux, you can add byteman to your project and use it on any os. Byteman allows user to inject custom code into running java classes, see documentation.