public interface CodeProvider
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
COBERTURA_CLASSMAP_METHOD_NAME
Name of a method that will to be injected into instrumented class that is responsible for storing
class-map (information on mapping of counter identifiers into lines, jumps and switch-touches).
|
static java.lang.String |
COBERTURA_COUNTERS_FIELD_NAME
Name of a field that have to be injected into instrumented class that is responsible for storing counters
|
static java.lang.String |
COBERTURA_GET_AND_RESET_COUNTERS_METHOD_NAME
Name of a method that have to be injected into instrumented class that is responsible for reading
value of given counter.
|
static java.lang.String |
COBERTURA_INIT_METHOD_NAME
Name of method that will initialize internal counters variable.
|
Modifier and Type | Method and Description |
---|---|
void |
generateCallCoberturaInitMethod(org.objectweb.asm.MethodVisitor mv,
java.lang.String className) |
void |
generateCoberturaClassMapMethod(org.objectweb.asm.ClassVisitor cv,
ClassMap classMap)
The version of cobertura prior to 1.10 used *.ser file to store information of lines, jumps, switches and other
constructions used in the class.
|
void |
generateCoberturaGetAndResetCountersMethod(org.objectweb.asm.ClassVisitor cv,
java.lang.String className)
Generate method "__cobertura_get_and_reset_counters" that is accessor to couters.
|
void |
generateCoberturaInitMethod(org.objectweb.asm.ClassVisitor cv,
java.lang.String className,
int countersCnt) |
void |
generateCodeThatIncrementsCoberturaCounter(org.objectweb.asm.MethodVisitor nextMethodVisitor,
java.lang.Integer counterId,
java.lang.String className)
Injects code that increments counter given by parameter.
|
void |
generateCodeThatIncrementsCoberturaCounterFromInternalVariable(org.objectweb.asm.MethodVisitor nextMethodVisitor,
int lastJumpIdVariableIndex,
java.lang.String className)
Injects code that increments counter given by internal variable.
|
void |
generateCodeThatIncrementsCoberturaCounterIfVariableEqualsAndCleanVariable(org.objectweb.asm.MethodVisitor nextMethodVisitor,
java.lang.Integer neededJumpCounterIdVariableValue,
java.lang.Integer counterIdToIncrement,
int lastJumpIdVariableIndex,
java.lang.String className)
Injects code that behaves the same as such a code snippet:
if (value('lastJumpIdVariableIndex')==neededJumpCounterIdVariableValue){
cobertura_counters.increment(counterIdToIncrement);
}
This snippet is used in switch case of switch statement.
|
void |
generateCodeThatSetsJumpCounterIdVariable(org.objectweb.asm.MethodVisitor nextMethodVisitor,
int new_value,
int lastJumpIdVariableIndex)
Injects code that sets internal variable (identified by lastJumpIdVariableIndex) to given value.
|
void |
generateCodeThatZeroJumpCounterIdVariable(org.objectweb.asm.MethodVisitor nextMethodVisitor,
int lastJumpIdVariableIndex)
Injects code that sets internal variable (identified by lastJumpIdVariableIndex) to zero.
|
void |
generateCountersField(org.objectweb.asm.ClassVisitor cv)
Generates fields injected into instrumented class by cobertura.
|
static final java.lang.String COBERTURA_COUNTERS_FIELD_NAME
static final java.lang.String COBERTURA_CLASSMAP_METHOD_NAME
static final java.lang.String COBERTURA_INIT_METHOD_NAME
static final java.lang.String COBERTURA_GET_AND_RESET_COUNTERS_METHOD_NAME
void generateCountersField(org.objectweb.asm.ClassVisitor cv)
cv
- - ClassVisitor that is listener of code-generation eventsvoid generateCodeThatIncrementsCoberturaCounter(org.objectweb.asm.MethodVisitor nextMethodVisitor, java.lang.Integer counterId, java.lang.String className)
nextMethodVisitor
- - MethodVisitor
that is listener of code-generation eventscounterId
- - counterId of counter that have to be incrementedclassName
- - internal name (asm) of class being instrumentedvoid generateCodeThatIncrementsCoberturaCounterFromInternalVariable(org.objectweb.asm.MethodVisitor nextMethodVisitor, int lastJumpIdVariableIndex, java.lang.String className)
generateCodeThatSetsJumpCounterIdVariable(MethodVisitor, int, int)
to some counterId and in the target label, the counter identified by the variable is incremented.
longnextMethodVisitor
- - MethodVisitor
that is listener of code-generation eventslastJumpIdVariableIndex
- - id of the variable used to store counterId that have to be incrementedclassName
- - internal name (asm) of class being instrumentedvoid generateCodeThatSetsJumpCounterIdVariable(org.objectweb.asm.MethodVisitor nextMethodVisitor, int new_value, int lastJumpIdVariableIndex)
nextMethodVisitor
- - MethodVisitor
that is listener of code-generation eventsnew_value
- - value to set the variable tolastJumpIdVariableIndex
- - index of variable that have to be setvoid generateCodeThatZeroJumpCounterIdVariable(org.objectweb.asm.MethodVisitor nextMethodVisitor, int lastJumpIdVariableIndex)
nextMethodVisitor
- - MethodVisitor
that is listener of code-generation eventslastJumpIdVariableIndex
- - index of variable that have to be setvoid generateCodeThatIncrementsCoberturaCounterIfVariableEqualsAndCleanVariable(org.objectweb.asm.MethodVisitor nextMethodVisitor, java.lang.Integer neededJumpCounterIdVariableValue, java.lang.Integer counterIdToIncrement, int lastJumpIdVariableIndex, java.lang.String className)
if (value('lastJumpIdVariableIndex')==neededJumpCounterIdVariableValue){ cobertura_counters.increment(counterIdToIncrement); }This snippet is used in switch case of switch statement. We have a label and we want to ensure that we are executing the label in effect of switch statement-jump, and not other JUMP or fall-throught.
void generateCoberturaClassMapMethod(org.objectweb.asm.ClassVisitor cv, ClassMap classMap)
cv
- - listener used to inject the codeclassMap
- - structure that is keeping all collected information about the class. The information from the structure will be stored as
method body.void generateCoberturaGetAndResetCountersMethod(org.objectweb.asm.ClassVisitor cv, java.lang.String className)
cv
- - listener used to inject the codevoid generateCoberturaInitMethod(org.objectweb.asm.ClassVisitor cv, java.lang.String className, int countersCnt)
void generateCallCoberturaInitMethod(org.objectweb.asm.MethodVisitor mv, java.lang.String className)