I need to programmatically instrument the lines of code of a method so that I can know what lines were touched or not by a certain execution – I want to have a map between the line numbers and if they were run or not.
So far, I have been using JaCoCo to perform this instrumentation. But JaCoCo instruments the whole class and I want to have control of what methods are instrumented.
Can I do this with libraries like ASM, BCEL or javassist? If so, can anyone point me to some documentation or tutorial?
You can look at Cobertura source code (that itself uses ASM). It is not a tutorial, but on the other hand, it is a real world example, and not a toy.