com.vladium.emma.instr
Class InstrVisitor
java.lang.Object
com.vladium.jcd.cls.AbstractClassDefVisitor
com.vladium.emma.instr.InstrVisitor
- All Implemented Interfaces:
- IAttributeVisitor, IClassDefVisitor, IOpcodes, IConstants
public final class InstrVisitor
- extends AbstractClassDefVisitor
- implements IClassDefVisitor, IAttributeVisitor, IOpcodes, IConstants
- Author:
- Vlad Roubtsov, (C) 2003
Fields inherited from interface com.vladium.jcd.opcodes.IOpcodes |
_aaload, _aastore, _aconst_null, _aload, _aload_0, _aload_1, _aload_2, _aload_3, _anewarray, _areturn, _arraylength, _astore, _astore_0, _astore_1, _astore_2, _astore_3, _athrow, _baload, _bastore, _bipush, _breakpoint, _caload, _castore, _checkcast, _d2f, _d2i, _d2l, _dadd, _daload, _dastore, _dcmpg, _dcmpl, _dconst_0, _dconst_1, _ddiv, _dload, _dload_0, _dload_1, _dload_2, _dload_3, _dmul, _dneg, _drem, _dreturn, _dstore, _dstore_0, _dstore_1, _dstore_2, _dstore_3, _dsub, _dup, _dup_x1, _dup_x2, _dup2, _dup2_x1, _dup2_x2, _f2d, _f2i, _f2l, _fadd, _faload, _fastore, _fcmpg, _fcmpl, _fconst_0, _fconst_1, _fconst_2, _fdiv, _fload, _fload_0, _fload_1, _fload_2, _fload_3, _fmul, _fneg, _frem, _freturn, _fstore, _fstore_0, _fstore_1, _fstore_2, _fstore_3, _fsub, _getfield, _getstatic, _goto, _goto_w, _i2b, _i2c, _i2d, _i2f, _i2l, _i2s, _iadd, _iaload, _iand, _iastore, _iconst_0, _iconst_1, _iconst_2, _iconst_3, _iconst_4, _iconst_5, _iconst_m1, _idiv, _if_acmpeq, _if_acmpne, _if_icmpeq, _if_icmpge, _if_icmpgt, _if_icmple, _if_icmplt, _if_icmpne, _ifeq, _ifge, _ifgt, _ifle, _iflt, _ifne, _ifnonnull, _ifnull, _iinc, _iload, _iload_0, _iload_1, _iload_2, _iload_3, _impdep1, _impdep2, _imul, _ineg, _instanceof, _invokeinterface, _invokespecial, _invokestatic, _invokevirtual, _ior, _irem, _ireturn, _ishl, _ishr, _istore, _istore_0, _istore_1, _istore_2, _istore_3, _isub, _iushr, _ixor, _jsr, _jsr_w, _l2d, _l2f, _l2i, _ladd, _laload, _land, _lastore, _lcmp, _lconst_0, _lconst_1, _ldc, _ldc_w, _ldc2_w, _ldiv, _lload, _lload_0, _lload_1, _lload_2, _lload_3, _lmul, _lneg, _lookupswitch, _lor, _lrem, _lreturn, _lshl, _lshr, _lstore, _lstore_0, _lstore_1, _lstore_2, _lstore_3, _lsub, _lushr, _lxor, _monitorenter, _monitorexit, _multianewarray, _new, _newarray, _nop, _pop, _pop2, _putfield, _putstatic, _ret, _return, _saload, _sastore, _sipush, _swap, _tableswitch, _unused, _wide, BRANCHES, COMPOUND_CONDITIONAL_BRANCHES, CONDITIONAL_BRANCHES, MNEMONICS, NARROW_SIZE, UNCONDITIONAL_BRANCHES, WIDE_SIZE |
Method Summary |
private void |
consumeSignatureData(int methodID,
int[] basicBlockOffsets)
|
private static int |
lowbound(int[] values,
int x)
Returns the maximum index 'i' such that (values[i] <= x). |
void |
process(ClassDef cls,
boolean ignoreAlreadyInstrumented,
boolean instrument,
boolean metadata,
InstrVisitor.InstrResult out)
Analyzes 'cls' and/or instruments it for coverage:
if 'instrument' is true, the class definition is instrumented for
coverage if that is feasible
if 'metadata' is true, the class definition is analysed
to create a ClassDescriptor for the original class definition
This method returns null if 'metadata' is 'false' *or* if 'cls' is an
interface [the latter precludes coverage of interface static
initializers and may be removed in the future]. |
private void |
reset()
|
private void |
setClassName(java.lang.String fullName)
|
java.lang.Object |
visit(BridgeAttribute_info attribute,
java.lang.Object ctx)
|
java.lang.Object |
visit(ClassDef ignore,
java.lang.Object ctx)
|
java.lang.Object |
visit(CodeAttribute_info attribute,
java.lang.Object ctx)
|
java.lang.Object |
visit(ConstantValueAttribute_info attribute,
java.lang.Object ctx)
|
java.lang.Object |
visit(ExceptionsAttribute_info attribute,
java.lang.Object ctx)
|
java.lang.Object |
visit(GenericAttribute_info attribute,
java.lang.Object ctx)
|
java.lang.Object |
visit(IAttributeCollection attributes,
java.lang.Object ctx)
|
java.lang.Object |
visit(IMethodCollection methods,
java.lang.Object ctx)
|
java.lang.Object |
visit(InnerClassesAttribute_info attribute,
java.lang.Object ctx)
|
java.lang.Object |
visit(LineNumberTableAttribute_info attribute,
java.lang.Object ctx)
|
java.lang.Object |
visit(SourceFileAttribute_info attribute,
java.lang.Object ctx)
|
java.lang.Object |
visit(SyntheticAttribute_info attribute,
java.lang.Object ctx)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
m_excludeSyntheticMethods
private final boolean m_excludeSyntheticMethods
m_excludeBridgeMethods
private final boolean m_excludeBridgeMethods
m_doSUIDCompensation
private final boolean m_doSUIDCompensation
m_log
private final Logger m_log
m_warningIssued
private boolean m_warningIssued
m_instrument
private boolean m_instrument
m_metadata
private boolean m_metadata
m_ignoreAlreadyInstrumented
private boolean m_ignoreAlreadyInstrumented
m_cls
ClassDef m_cls
m_classPackageName
private java.lang.String m_classPackageName
m_className
private java.lang.String m_className
m_classSrcFileName
private java.lang.String m_classSrcFileName
m_classBlockMetadata
private int[][][] m_classBlockMetadata
m_classMethodDescriptors
private MethodDescriptor[] m_classMethodDescriptors
m_syntheticStringIndex
private int m_syntheticStringIndex
m_coverageFieldrefIndex
int m_coverageFieldrefIndex
m_registerMethodrefIndex
private int m_registerMethodrefIndex
m_preclinitMethodrefIndex
int m_preclinitMethodrefIndex
m_classNameConstantIndex
int m_classNameConstantIndex
m_stampIndex
private int m_stampIndex
m_clinitID
private int m_clinitID
m_clinitStatus
private int m_clinitStatus
m_classInstrMethodCount
int m_classInstrMethodCount
m_classBlockCounts
int[] m_classBlockCounts
m_classSignature
private long m_classSignature
m_methodID
int m_methodID
m_methodName
private java.lang.String m_methodName
m_methodFirstLine
private int m_methodFirstLine
m_methodBlockOffsets
private int[] m_methodBlockOffsets
m_methodBlockSizes
private int[] m_methodBlockSizes
m_methodJumpAdjOffsets
private int[] m_methodJumpAdjOffsets
m_methodJumpAdjValues
private int[] m_methodJumpAdjValues
NBEAST
private static final long NBEAST
- See Also:
- Constant Field Values
COVERAGE_FIELD_NAME
private static final java.lang.String COVERAGE_FIELD_NAME
- See Also:
- Constant Field Values
SUID_FIELD_NAME
private static final java.lang.String SUID_FIELD_NAME
- See Also:
- Constant Field Values
PRECLINIT_METHOD_NAME
private static final java.lang.String PRECLINIT_METHOD_NAME
- See Also:
- Constant Field Values
JAVA_IO_SERIALIZABLE_NAME
private static final java.lang.String JAVA_IO_SERIALIZABLE_NAME
- See Also:
- Constant Field Values
JAVA_IO_EXTERNALIZABLE_NAME
private static final java.lang.String JAVA_IO_EXTERNALIZABLE_NAME
- See Also:
- Constant Field Values
EMIT_CTX_MIN_INIT_CAPACITY
private static final int EMIT_CTX_MIN_INIT_CAPACITY
- See Also:
- Constant Field Values
PRECLINIT_INIT_CAPACITY
private static final int PRECLINIT_INIT_CAPACITY
- See Also:
- Constant Field Values
MARK_ADDED_ELEMENTS_SYNTHETIC
private static final boolean MARK_ADDED_ELEMENTS_SYNTHETIC
- See Also:
- Constant Field Values
SKIP_SYNTHETIC_CLASSES
private static final boolean SKIP_SYNTHETIC_CLASSES
- See Also:
- Constant Field Values
LINE_NUMBER_COMPARATOR
private static final InstrVisitor.LineNumberComparator LINE_NUMBER_COMPARATOR
EMPTY_BYTE_ARRAY
private static final byte[] EMPTY_BYTE_ARRAY
InstrVisitor
public InstrVisitor(CoverageOptions options)
process
public void process(ClassDef cls,
boolean ignoreAlreadyInstrumented,
boolean instrument,
boolean metadata,
InstrVisitor.InstrResult out)
- Analyzes 'cls' and/or instruments it for coverage:
- if 'instrument' is true, the class definition is instrumented for
coverage if that is feasible
- if 'metadata' is true, the class definition is analysed
to create a
ClassDescriptor
for the original class definition
This method returns null if 'metadata' is 'false' *or* if 'cls' is an
interface [the latter precludes coverage of interface static
initializers and may be removed in the future].
NOTE: if 'instrument' is 'true', the caller should always assume that 'cls'
has been mutated by this method even if it returned null. The caller should
then revert to the original class definition that was created as a
cls.clone()
or by retaining the original definition bytes.
This part of contract is for efficienty and also simplifies the implementation.
visit
public java.lang.Object visit(ClassDef ignore,
java.lang.Object ctx)
- Specified by:
visit
in interface IClassDefVisitor
- Overrides:
visit
in class AbstractClassDefVisitor
visit
public java.lang.Object visit(IMethodCollection methods,
java.lang.Object ctx)
- Specified by:
visit
in interface IClassDefVisitor
- Overrides:
visit
in class AbstractClassDefVisitor
visit
public java.lang.Object visit(IAttributeCollection attributes,
java.lang.Object ctx)
- Specified by:
visit
in interface IClassDefVisitor
- Overrides:
visit
in class AbstractClassDefVisitor
visit
public java.lang.Object visit(CodeAttribute_info attribute,
java.lang.Object ctx)
- Specified by:
visit
in interface IAttributeVisitor
visit
public java.lang.Object visit(LineNumberTableAttribute_info attribute,
java.lang.Object ctx)
- Specified by:
visit
in interface IAttributeVisitor
visit
public java.lang.Object visit(ExceptionsAttribute_info attribute,
java.lang.Object ctx)
- Specified by:
visit
in interface IAttributeVisitor
visit
public java.lang.Object visit(ConstantValueAttribute_info attribute,
java.lang.Object ctx)
- Specified by:
visit
in interface IAttributeVisitor
visit
public java.lang.Object visit(SourceFileAttribute_info attribute,
java.lang.Object ctx)
- Specified by:
visit
in interface IAttributeVisitor
visit
public java.lang.Object visit(SyntheticAttribute_info attribute,
java.lang.Object ctx)
- Specified by:
visit
in interface IAttributeVisitor
visit
public java.lang.Object visit(BridgeAttribute_info attribute,
java.lang.Object ctx)
- Specified by:
visit
in interface IAttributeVisitor
visit
public java.lang.Object visit(InnerClassesAttribute_info attribute,
java.lang.Object ctx)
- Specified by:
visit
in interface IAttributeVisitor
visit
public java.lang.Object visit(GenericAttribute_info attribute,
java.lang.Object ctx)
- Specified by:
visit
in interface IAttributeVisitor
setClassName
private void setClassName(java.lang.String fullName)
consumeSignatureData
private void consumeSignatureData(int methodID,
int[] basicBlockOffsets)
lowbound
private static int lowbound(int[] values,
int x)
- Returns the maximum index 'i' such that (values[i] <= x). values[]
contains distinct non-negative integers in increasing order. values[0] is 0,
'x' is non-negative.
Edge case:
returns values.length-1 if values [values.length - 1] < x
reset
private void reset()