Class MethodAnalyzer
- java.lang.Object
-
- org.objectweb.asm.MethodVisitor
-
- org.jacoco.core.internal.flow.MethodProbesVisitor
-
- org.jacoco.core.internal.analysis.MethodAnalyzer
-
public class MethodAnalyzer extends MethodProbesVisitor
AMethodProbesVisitorthat builds theInstructions of a method to calculate the detailed execution status.
-
-
Field Summary
Fields Modifier and Type Field Description private InstructionsBuilderbuilderprivate org.objectweb.asm.tree.AbstractInsnNodecurrentNodeCurrent node of the ASM tree API
-
Constructor Summary
Constructors Constructor Description MethodAnalyzer(InstructionsBuilder builder)New instance that uses the given builder.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaccept(org.objectweb.asm.tree.MethodNode methodNode, org.objectweb.asm.MethodVisitor methodVisitor)This method can be overwritten to hook into the process of emitting the instructions of this method asvisitX()events.voidvisitFieldInsn(int opcode, java.lang.String owner, java.lang.String name, java.lang.String desc)voidvisitIincInsn(int var, int increment)voidvisitInsn(int opcode)voidvisitInsnWithProbe(int opcode, int probeId)Visits a zero operand instruction with a probe.voidvisitIntInsn(int opcode, int operand)voidvisitInvokeDynamicInsn(java.lang.String name, java.lang.String desc, org.objectweb.asm.Handle bsm, java.lang.Object... bsmArgs)voidvisitJumpInsn(int opcode, org.objectweb.asm.Label label)voidvisitJumpInsnWithProbe(int opcode, org.objectweb.asm.Label label, int probeId, IFrame frame)Visits a jump instruction.voidvisitLabel(org.objectweb.asm.Label label)voidvisitLdcInsn(java.lang.Object cst)voidvisitLineNumber(int line, org.objectweb.asm.Label start)voidvisitLookupSwitchInsn(org.objectweb.asm.Label dflt, int[] keys, org.objectweb.asm.Label[] labels)voidvisitLookupSwitchInsnWithProbes(org.objectweb.asm.Label dflt, int[] keys, org.objectweb.asm.Label[] labels, IFrame frame)Visits a LOOKUPSWITCH instruction with optional probes for each target label.voidvisitMethodInsn(int opcode, java.lang.String owner, java.lang.String name, java.lang.String desc, boolean itf)voidvisitMultiANewArrayInsn(java.lang.String desc, int dims)voidvisitProbe(int probeId)Visits an unconditional probe that should be inserted at the current position.private voidvisitSwitchInsn(org.objectweb.asm.Label dflt, org.objectweb.asm.Label[] labels)private voidvisitSwitchInsnWithProbes(org.objectweb.asm.Label dflt, org.objectweb.asm.Label[] labels)private voidvisitSwitchTarget(org.objectweb.asm.Label label, int branch)voidvisitTableSwitchInsn(int min, int max, org.objectweb.asm.Label dflt, org.objectweb.asm.Label... labels)voidvisitTableSwitchInsnWithProbes(int min, int max, org.objectweb.asm.Label dflt, org.objectweb.asm.Label[] labels, IFrame frame)Visits a TABLESWITCH instruction with optional probes for each target label.voidvisitTypeInsn(int opcode, java.lang.String type)voidvisitVarInsn(int opcode, int var)-
Methods inherited from class org.objectweb.asm.MethodVisitor
getDelegate, visitAnnotableParameterCount, visitAnnotation, visitAnnotationDefault, visitAttribute, visitCode, visitEnd, visitFrame, visitInsnAnnotation, visitLocalVariable, visitLocalVariableAnnotation, visitMaxs, visitMethodInsn, visitParameter, visitParameterAnnotation, visitTryCatchAnnotation, visitTryCatchBlock, visitTypeAnnotation
-
-
-
-
Field Detail
-
builder
private final InstructionsBuilder builder
-
currentNode
private org.objectweb.asm.tree.AbstractInsnNode currentNode
Current node of the ASM tree API
-
-
Constructor Detail
-
MethodAnalyzer
MethodAnalyzer(InstructionsBuilder builder)
New instance that uses the given builder.
-
-
Method Detail
-
accept
public void accept(org.objectweb.asm.tree.MethodNode methodNode, org.objectweb.asm.MethodVisitor methodVisitor)Description copied from class:MethodProbesVisitorThis method can be overwritten to hook into the process of emitting the instructions of this method asvisitX()events.- Overrides:
acceptin classMethodProbesVisitor- Parameters:
methodNode- the content to emitmethodVisitor- A visitor to emit the content to. Note that this is not necessarily this visitor instance but some wrapper which calculates the probes.
-
visitLabel
public void visitLabel(org.objectweb.asm.Label label)
- Overrides:
visitLabelin classorg.objectweb.asm.MethodVisitor
-
visitLineNumber
public void visitLineNumber(int line, org.objectweb.asm.Label start)- Overrides:
visitLineNumberin classorg.objectweb.asm.MethodVisitor
-
visitInsn
public void visitInsn(int opcode)
- Overrides:
visitInsnin classorg.objectweb.asm.MethodVisitor
-
visitIntInsn
public void visitIntInsn(int opcode, int operand)- Overrides:
visitIntInsnin classorg.objectweb.asm.MethodVisitor
-
visitVarInsn
public void visitVarInsn(int opcode, int var)- Overrides:
visitVarInsnin classorg.objectweb.asm.MethodVisitor
-
visitTypeInsn
public void visitTypeInsn(int opcode, java.lang.String type)- Overrides:
visitTypeInsnin classorg.objectweb.asm.MethodVisitor
-
visitFieldInsn
public void visitFieldInsn(int opcode, java.lang.String owner, java.lang.String name, java.lang.String desc)- Overrides:
visitFieldInsnin classorg.objectweb.asm.MethodVisitor
-
visitMethodInsn
public void visitMethodInsn(int opcode, java.lang.String owner, java.lang.String name, java.lang.String desc, boolean itf)- Overrides:
visitMethodInsnin classorg.objectweb.asm.MethodVisitor
-
visitInvokeDynamicInsn
public void visitInvokeDynamicInsn(java.lang.String name, java.lang.String desc, org.objectweb.asm.Handle bsm, java.lang.Object... bsmArgs)- Overrides:
visitInvokeDynamicInsnin classorg.objectweb.asm.MethodVisitor
-
visitJumpInsn
public void visitJumpInsn(int opcode, org.objectweb.asm.Label label)- Overrides:
visitJumpInsnin classorg.objectweb.asm.MethodVisitor
-
visitLdcInsn
public void visitLdcInsn(java.lang.Object cst)
- Overrides:
visitLdcInsnin classorg.objectweb.asm.MethodVisitor
-
visitIincInsn
public void visitIincInsn(int var, int increment)- Overrides:
visitIincInsnin classorg.objectweb.asm.MethodVisitor
-
visitTableSwitchInsn
public void visitTableSwitchInsn(int min, int max, org.objectweb.asm.Label dflt, org.objectweb.asm.Label... labels)- Overrides:
visitTableSwitchInsnin classorg.objectweb.asm.MethodVisitor
-
visitLookupSwitchInsn
public void visitLookupSwitchInsn(org.objectweb.asm.Label dflt, int[] keys, org.objectweb.asm.Label[] labels)- Overrides:
visitLookupSwitchInsnin classorg.objectweb.asm.MethodVisitor
-
visitSwitchInsn
private void visitSwitchInsn(org.objectweb.asm.Label dflt, org.objectweb.asm.Label[] labels)
-
visitMultiANewArrayInsn
public void visitMultiANewArrayInsn(java.lang.String desc, int dims)- Overrides:
visitMultiANewArrayInsnin classorg.objectweb.asm.MethodVisitor
-
visitProbe
public void visitProbe(int probeId)
Description copied from class:MethodProbesVisitorVisits an unconditional probe that should be inserted at the current position.- Overrides:
visitProbein classMethodProbesVisitor- Parameters:
probeId- id of the probe to insert
-
visitJumpInsnWithProbe
public void visitJumpInsnWithProbe(int opcode, org.objectweb.asm.Label label, int probeId, IFrame frame)Description copied from class:MethodProbesVisitorVisits a jump instruction. A probe with the given id should be inserted in a way that it is executed only when the jump to the given label is executed.- Overrides:
visitJumpInsnWithProbein classMethodProbesVisitor- Parameters:
opcode- the opcode of the type instruction to be visited. This opcode is either IFEQ, IFNE, IFLT, IFGE, IFGT, IFLE, IF_ICMPEQ, IF_ICMPNE, IF_ICMPLT, IF_ICMPGE, IF_ICMPGT, IF_ICMPLE, IF_ACMPEQ, IF_ACMPNE, GOTO, IFNULL or IFNONNULL.label- the operand of the instruction to be visited. This operand is a label that designates the instruction to which the jump instruction may jump.probeId- id of the probeframe- stackmap frame status after the execution of the jump instruction. The instance is only valid with the call of this method.- See Also:
MethodVisitor.visitJumpInsn(int, Label)
-
visitInsnWithProbe
public void visitInsnWithProbe(int opcode, int probeId)Description copied from class:MethodProbesVisitorVisits a zero operand instruction with a probe. This event is used only for instructions that terminate the method. Therefore the probe must be inserted before the actual instruction.- Overrides:
visitInsnWithProbein classMethodProbesVisitor- Parameters:
opcode- the opcode of the instruction to be visited. This opcode is either IRETURN, LRETURN, FRETURN, DRETURN, ARETURN, RETURN or ATHROW.probeId- id of the probe- See Also:
MethodVisitor.visitInsn(int)
-
visitTableSwitchInsnWithProbes
public void visitTableSwitchInsnWithProbes(int min, int max, org.objectweb.asm.Label dflt, org.objectweb.asm.Label[] labels, IFrame frame)Description copied from class:MethodProbesVisitorVisits a TABLESWITCH instruction with optional probes for each target label. Implementations can be optimized based on the fact that the same target labels will always have the same probe id within a call to this method. The probe id for each label can be obtained withLabelInfo.getProbeId(Label).- Overrides:
visitTableSwitchInsnWithProbesin classMethodProbesVisitor- Parameters:
min- the minimum key value.max- the maximum key value.dflt- beginning of the default handler block.labels- beginnings of the handler blocks.labels[i]is the beginning of the handler block for themin + ikey.frame- stackmap frame status after the execution of the switch instruction. The instance is only valid with the call of this method.- See Also:
MethodVisitor.visitTableSwitchInsn(int, int, Label, Label[])
-
visitLookupSwitchInsnWithProbes
public void visitLookupSwitchInsnWithProbes(org.objectweb.asm.Label dflt, int[] keys, org.objectweb.asm.Label[] labels, IFrame frame)Description copied from class:MethodProbesVisitorVisits a LOOKUPSWITCH instruction with optional probes for each target label. Implementations can be optimized based on the fact that the same target labels will always have the same probe id within a call to this method. The probe id for each label can be obtained withLabelInfo.getProbeId(Label).- Overrides:
visitLookupSwitchInsnWithProbesin classMethodProbesVisitor- Parameters:
dflt- beginning of the default handler block.keys- the values of the keys.labels- beginnings of the handler blocks.labels[i]is the beginning of the handler block for thekeys[i]key.frame- stackmap frame status after the execution of the switch instruction. The instance is only valid with the call of this method.- See Also:
MethodVisitor.visitLookupSwitchInsn(Label, int[], Label[])
-
visitSwitchInsnWithProbes
private void visitSwitchInsnWithProbes(org.objectweb.asm.Label dflt, org.objectweb.asm.Label[] labels)
-
visitSwitchTarget
private void visitSwitchTarget(org.objectweb.asm.Label label, int branch)
-
-