We're building a monitoring tool for our enterprise-class app that uses Javassist for the instrumenting portion. We have method entry/exit instrumentation working fine; now we'd like to be able to instrument code blocks *within* methods. For example, given method frodo(), and a suspicious for() loop within that method, we'd like to be able to 1) identify where in the method the for() loop lives; and 2) wrap the loop with our timing code.
Perhaps a way to instrument a method block bounded by line numbers? If we have to go to the bytecode api, that's fine, but I could use some guidance from the community on how best to approach this.
Thanks for an excellent tool.
david
Uh oh. RTFM, I guess. Is the proper way to do this CtMethod.insertAt()?