public final class InstrVisitor extends AbstractClassDefVisitor implements IClassDefVisitor, IAttributeVisitor, IOpcodes, IConstants
Modifier and Type | Class and Description |
---|---|
private static class |
InstrVisitor.Block |
private static class |
InstrVisitor.BlockList |
(package private) static class |
InstrVisitor.BlockSegment |
(package private) static class |
InstrVisitor.Branch
A Branch does not add any maxlocals/maxstack requirements.
|
(package private) static class |
InstrVisitor.clinitHeader |
(package private) static class |
InstrVisitor.CodeSegment
TODO: CodeSegment right now must be 100% position-independent code;
otherwise it must follow maxlengtt() Branch pattern...
|
(package private) static class |
InstrVisitor.EmitCtx |
(package private) static class |
InstrVisitor.IFJUMP2 |
static class |
InstrVisitor.InstrResult |
(package private) static class |
InstrVisitor.JUMP2 |
(package private) static class |
InstrVisitor.JUMP4 |
private static class |
InstrVisitor.LineNumberComparator |
(package private) static class |
InstrVisitor.LOOKUPSWITCH |
(package private) static class |
InstrVisitor.methodHeader |
(package private) static class |
InstrVisitor.RET |
(package private) static class |
InstrVisitor.TABLESWITCH |
(package private) static class |
InstrVisitor.TERMINATE |
IOpcodes.clinit
Modifier and Type | Field and Description |
---|---|
private static java.lang.String |
COVERAGE_FIELD_NAME |
private static int |
EMIT_CTX_MIN_INIT_CAPACITY |
private static byte[] |
EMPTY_BYTE_ARRAY |
private static java.lang.String |
JAVA_IO_EXTERNALIZABLE_NAME |
private static java.lang.String |
JAVA_IO_SERIALIZABLE_NAME |
private static InstrVisitor.LineNumberComparator |
LINE_NUMBER_COMPARATOR |
(package private) int[] |
m_classBlockCounts |
private int[][][] |
m_classBlockMetadata |
(package private) int |
m_classInstrMethodCount |
private MethodDescriptor[] |
m_classMethodDescriptors |
private java.lang.String |
m_className |
(package private) int |
m_classNameConstantIndex |
private java.lang.String |
m_classPackageName |
private long |
m_classSignature |
private java.lang.String |
m_classSrcFileName |
private int |
m_clinitID |
private int |
m_clinitStatus |
(package private) ClassDef |
m_cls |
(package private) int |
m_coverageFieldrefIndex |
private boolean |
m_doSUIDCompensation |
private boolean |
m_excludeBridgeMethods |
private boolean |
m_excludeSyntheticMethods |
private boolean |
m_ignoreAlreadyInstrumented |
private boolean |
m_instrument |
private Logger |
m_log |
private boolean |
m_metadata |
private int[] |
m_methodBlockOffsets |
private int[] |
m_methodBlockSizes |
private int |
m_methodFirstLine |
(package private) int |
m_methodID |
private int[] |
m_methodJumpAdjOffsets |
private int[] |
m_methodJumpAdjValues |
private java.lang.String |
m_methodName |
(package private) int |
m_preclinitMethodrefIndex |
private int |
m_registerMethodrefIndex |
private int |
m_stampIndex |
private int |
m_syntheticStringIndex |
private boolean |
m_warningIssued |
private static boolean |
MARK_ADDED_ELEMENTS_SYNTHETIC |
private static long |
NBEAST |
private static int |
PRECLINIT_INIT_CAPACITY |
private static java.lang.String |
PRECLINIT_METHOD_NAME |
private static boolean |
SKIP_SYNTHETIC_CLASSES |
private static java.lang.String |
SUID_FIELD_NAME |
_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
EMPTY_FILE_ARRAY, EMPTY_INT_ARRAY, EMPTY_STRING_ARRAY, EOL, INDENT_INCREMENT
Constructor and Description |
---|
InstrVisitor(CoverageOptions options) |
Modifier and Type | Method and Description |
---|---|
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) |
visit, visit, visit
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
visit, visit, visit
private final boolean m_excludeSyntheticMethods
private final boolean m_excludeBridgeMethods
private final boolean m_doSUIDCompensation
private final Logger m_log
private boolean m_warningIssued
private boolean m_instrument
private boolean m_metadata
private boolean m_ignoreAlreadyInstrumented
ClassDef m_cls
private java.lang.String m_classPackageName
private java.lang.String m_className
private java.lang.String m_classSrcFileName
private int[][][] m_classBlockMetadata
private MethodDescriptor[] m_classMethodDescriptors
private int m_syntheticStringIndex
int m_coverageFieldrefIndex
private int m_registerMethodrefIndex
int m_preclinitMethodrefIndex
int m_classNameConstantIndex
private int m_stampIndex
private int m_clinitID
private int m_clinitStatus
int m_classInstrMethodCount
int[] m_classBlockCounts
private long m_classSignature
int m_methodID
private java.lang.String m_methodName
private int m_methodFirstLine
private int[] m_methodBlockOffsets
private int[] m_methodBlockSizes
private int[] m_methodJumpAdjOffsets
private int[] m_methodJumpAdjValues
private static final long NBEAST
private static final java.lang.String COVERAGE_FIELD_NAME
private static final java.lang.String SUID_FIELD_NAME
private static final java.lang.String PRECLINIT_METHOD_NAME
private static final java.lang.String JAVA_IO_SERIALIZABLE_NAME
private static final java.lang.String JAVA_IO_EXTERNALIZABLE_NAME
private static final int EMIT_CTX_MIN_INIT_CAPACITY
private static final int PRECLINIT_INIT_CAPACITY
private static final boolean MARK_ADDED_ELEMENTS_SYNTHETIC
private static final boolean SKIP_SYNTHETIC_CLASSES
private static final InstrVisitor.LineNumberComparator LINE_NUMBER_COMPARATOR
private static final byte[] EMPTY_BYTE_ARRAY
public InstrVisitor(CoverageOptions options)
public void process(ClassDef cls, boolean ignoreAlreadyInstrumented, boolean instrument, boolean metadata, InstrVisitor.InstrResult out)
ClassDescriptor
for the original class definition
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.
public java.lang.Object visit(ClassDef ignore, java.lang.Object ctx)
visit
in interface IClassDefVisitor
visit
in class AbstractClassDefVisitor
public java.lang.Object visit(IMethodCollection methods, java.lang.Object ctx)
visit
in interface IClassDefVisitor
visit
in class AbstractClassDefVisitor
public java.lang.Object visit(IAttributeCollection attributes, java.lang.Object ctx)
visit
in interface IClassDefVisitor
visit
in class AbstractClassDefVisitor
public java.lang.Object visit(CodeAttribute_info attribute, java.lang.Object ctx)
visit
in interface IAttributeVisitor
public java.lang.Object visit(LineNumberTableAttribute_info attribute, java.lang.Object ctx)
visit
in interface IAttributeVisitor
public java.lang.Object visit(ExceptionsAttribute_info attribute, java.lang.Object ctx)
visit
in interface IAttributeVisitor
public java.lang.Object visit(ConstantValueAttribute_info attribute, java.lang.Object ctx)
visit
in interface IAttributeVisitor
public java.lang.Object visit(SourceFileAttribute_info attribute, java.lang.Object ctx)
visit
in interface IAttributeVisitor
public java.lang.Object visit(SyntheticAttribute_info attribute, java.lang.Object ctx)
visit
in interface IAttributeVisitor
public java.lang.Object visit(BridgeAttribute_info attribute, java.lang.Object ctx)
visit
in interface IAttributeVisitor
public java.lang.Object visit(InnerClassesAttribute_info attribute, java.lang.Object ctx)
visit
in interface IAttributeVisitor
public java.lang.Object visit(GenericAttribute_info attribute, java.lang.Object ctx)
visit
in interface IAttributeVisitor
private void setClassName(java.lang.String fullName)
private void consumeSignatureData(int methodID, int[] basicBlockOffsets)
private static int lowbound(int[] values, int x)
private void reset()