Dynamic and static instrumentation

If you are generating code coverage statistics from the command line or in an ANT task, then you can choose either dynamic or static instrumentation of your target classes.

The code coverage feature works by inserting code into your Java™ classes at the start of every executable unit. (An executable unit begins at the start of every basic block - a section of code that cannot be branched into or out of - and at any instruction that corresponds to a line of source code that is different than the previous instruction.) The code coverage feature uses the inserted code to collect statistics about the coverage of your application. The process of inserting code into your Java classes is called instrumentation.

Instrumentation can be either static or dynamic.

With dynamic instrumentation, the bytecode for you Java classes are instrumented at the time that they are loaded by the JVM. If you are working from a command line or an ANT task, then you can choose to use dynamic or static instrumentation.
Note: Dynamic instrumentation is the only instrumentation method used if you are working in the workbench.

With static instrumentation, the instrumentation code is inserted into the class files of your application and then the updated class files are saved on disk. In earlier version of the code coverage feature, all instrumentation was static. You can still use static instrumentation if you are working from a command line or an ANT task, but this instrumentation method is deprecated.


Feedback