public class AtomicArrayCodeProvider extends AbstractCodeProvider implements CodeProvider
The CodeProvider
uses AtomicArrayCodeProvider
to store counters.
FastArrayCodeProvider
.AbstractCodeProvider.Abcd
Modifier and Type | Field and Description |
---|---|
(package private) static java.lang.String |
COBERTURA_COUNTERS_FIELD_TYPE
Type of the generated field, that is used to store counters
|
CLASSMAP_LISTENER_INTERNALNAME, FAKE_COUNTER_ID
COBERTURA_CLASSMAP_METHOD_NAME, COBERTURA_COUNTERS_FIELD_NAME, COBERTURA_GET_AND_RESET_COUNTERS_METHOD_NAME, COBERTURA_INIT_METHOD_NAME
Constructor and Description |
---|
AtomicArrayCodeProvider() |
Modifier and Type | Method and Description |
---|---|
void |
generateCINITmethod(org.objectweb.asm.MethodVisitor mv,
java.lang.String className,
int counters_cnt)
Generates code that is injected into static constructor of an instrumented class.
|
void |
generateCoberturaGetAndResetCountersMethod(org.objectweb.asm.ClassVisitor cv,
java.lang.String className)
int[] __cobertura_get_and_reset_counters() {
int[] res = new int[counters.length()];
for(int i=0; i |
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 |
generateCountersField(org.objectweb.asm.ClassVisitor cv)
Generates fields injected into instrumented class by cobertura.
|
generateCallCoberturaInitMethod, generateCoberturaClassMapMethod, generateCoberturaInitMethod, generateCodeThatIncrementsCoberturaCounterIfVariableEqualsAndCleanVariable, generateCodeThatSetsJumpCounterIdVariable, generateCodeThatZeroJumpCounterIdVariable, generateRegisterClass
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
generateCallCoberturaInitMethod, generateCoberturaClassMapMethod, generateCoberturaInitMethod, generateCodeThatIncrementsCoberturaCounterIfVariableEqualsAndCleanVariable, generateCodeThatSetsJumpCounterIdVariable, generateCodeThatZeroJumpCounterIdVariable
static final java.lang.String COBERTURA_COUNTERS_FIELD_TYPE
public AtomicArrayCodeProvider()
public void generateCountersField(org.objectweb.asm.ClassVisitor cv)
CodeProvider
generateCountersField
in interface CodeProvider
cv
- - ClassVisitor that is listener of code-generation eventspublic void generateCINITmethod(org.objectweb.asm.MethodVisitor mv, java.lang.String className, int counters_cnt)
AbstractCodeProvider
CodeProvider.generateCountersField(ClassVisitor)
),
or execute other code that should be executed when the class it used for the first time. Registering the class in
TouchCollector
would be a bright idea.
It is expected that all counter will be set to zero after that operation.generateCINITmethod
in class AbstractCodeProvider
mv
- - MethodVisitor
that is listener of code-generation eventsclassName
- - internal name (asm) of class being instrumentedcounters_cnt
- - information about how many counters are expected to be used by instrumentation code.
In most cases the method is responsible for allocating objects that will be used to store counters.public void generateCodeThatIncrementsCoberturaCounter(org.objectweb.asm.MethodVisitor nextMethodVisitor, java.lang.Integer counterId, java.lang.String className)
CodeProvider
generateCodeThatIncrementsCoberturaCounter
in interface CodeProvider
nextMethodVisitor
- - MethodVisitor
that is listener of code-generation eventscounterId
- - counterId of counter that have to be incrementedclassName
- - internal name (asm) of class being instrumentedpublic void generateCodeThatIncrementsCoberturaCounterFromInternalVariable(org.objectweb.asm.MethodVisitor nextMethodVisitor, int lastJumpIdVariableIndex, java.lang.String className)
CodeProvider
CodeProvider.generateCodeThatSetsJumpCounterIdVariable(MethodVisitor, int, int)
to some counterId and in the target label, the counter identified by the variable is incremented.
longgenerateCodeThatIncrementsCoberturaCounterFromInternalVariable
in interface CodeProvider
nextMethodVisitor
- - 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 instrumentedpublic void generateCoberturaGetAndResetCountersMethod(org.objectweb.asm.ClassVisitor cv, java.lang.String className)
int[] __cobertura_get_and_reset_counters() { int[] res = new int[counters.length()]; for(int i=0; i
generateCoberturaGetAndResetCountersMethod
in interface CodeProvider
cv
- - listener used to inject the code