org.jacoco.core.internal.analysis
Class MethodAnalyzer

java.lang.Object
  extended by org.jacoco.core.internal.analysis.MethodAnalyzer
All Implemented Interfaces:
IMethodProbesVisitor, org.objectweb.asm.MethodVisitor

public class MethodAnalyzer
extends Object
implements IMethodProbesVisitor

A IMethodProbesVisitor that analyzes which statements and branches of a method has been executed based on given probe data.


Constructor Summary
MethodAnalyzer(String name, String desc, String signature, boolean[] executionData)
          New Method analyzer for the given probe data.
 
Method Summary
 IMethodCoverage getCoverage()
          Returns the coverage data for this method after this visitor has been processed.
 org.objectweb.asm.AnnotationVisitor visitAnnotation(String desc, boolean visible)
           
 org.objectweb.asm.AnnotationVisitor visitAnnotationDefault()
           
 void visitAttribute(org.objectweb.asm.Attribute attr)
           
 void visitCode()
           
 void visitEnd()
           
 void visitFieldInsn(int opcode, String owner, String name, String desc)
           
 void visitFrame(int type, int nLocal, Object[] local, int nStack, Object[] stack)
           
 void visitIincInsn(int var, int increment)
           
 void visitInsn(int opcode)
           
 void visitInsnWithProbe(int opcode, int probeId)
          Visits a zero operand instruction with a probe.
 void visitIntInsn(int opcode, int operand)
           
 void visitJumpInsn(int opcode, org.objectweb.asm.Label label)
           
 void visitJumpInsnWithProbe(int opcode, org.objectweb.asm.Label label, int probeId)
          Visits a jump instruction.
 void visitLabel(org.objectweb.asm.Label label)
           
 void visitLdcInsn(Object cst)
           
 void visitLineNumber(int line, org.objectweb.asm.Label start)
           
 void visitLocalVariable(String name, String desc, String signature, org.objectweb.asm.Label start, org.objectweb.asm.Label end, int index)
           
 void visitLookupSwitchInsn(org.objectweb.asm.Label dflt, int[] keys, org.objectweb.asm.Label[] labels)
           
 void visitLookupSwitchInsnWithProbes(org.objectweb.asm.Label dflt, int[] keys, org.objectweb.asm.Label[] labels)
          Visits a LOOKUPSWITCH instruction with optional probes for each target label.
 void visitMaxs(int maxStack, int maxLocals)
           
 void visitMethodInsn(int opcode, String owner, String name, String desc)
           
 void visitMultiANewArrayInsn(String desc, int dims)
           
 org.objectweb.asm.AnnotationVisitor visitParameterAnnotation(int parameter, String desc, boolean visible)
           
 void visitProbe(int probeId)
          Visits an unconditional probe that should be inserted at the current position.
 void visitTableSwitchInsn(int min, int max, org.objectweb.asm.Label dflt, org.objectweb.asm.Label[] labels)
           
 void visitTableSwitchInsnWithProbes(int min, int max, org.objectweb.asm.Label dflt, org.objectweb.asm.Label[] labels)
          Visits a TABLESWITCH instruction with optional probes for each target label.
 void visitTryCatchBlock(org.objectweb.asm.Label start, org.objectweb.asm.Label end, org.objectweb.asm.Label handler, String type)
           
 void visitTypeInsn(int opcode, String type)
           
 void visitVarInsn(int opcode, int var)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MethodAnalyzer

public MethodAnalyzer(String name,
                      String desc,
                      String signature,
                      boolean[] executionData)
New Method analyzer for the given probe data.

Parameters:
name - method name
desc - description of the method
signature - optional parameterized signature
executionData - recorded probe date of the containing class or null if the class is not executed at all
Method Detail

getCoverage

public IMethodCoverage getCoverage()
Returns the coverage data for this method after this visitor has been processed.

Returns:
coverage data for this method

visitLabel

public void visitLabel(org.objectweb.asm.Label label)
Specified by:
visitLabel in interface org.objectweb.asm.MethodVisitor

visitLineNumber

public void visitLineNumber(int line,
                            org.objectweb.asm.Label start)
Specified by:
visitLineNumber in interface org.objectweb.asm.MethodVisitor

visitInsn

public void visitInsn(int opcode)
Specified by:
visitInsn in interface org.objectweb.asm.MethodVisitor

visitIntInsn

public void visitIntInsn(int opcode,
                         int operand)
Specified by:
visitIntInsn in interface org.objectweb.asm.MethodVisitor

visitVarInsn

public void visitVarInsn(int opcode,
                         int var)
Specified by:
visitVarInsn in interface org.objectweb.asm.MethodVisitor

visitTypeInsn

public void visitTypeInsn(int opcode,
                          String type)
Specified by:
visitTypeInsn in interface org.objectweb.asm.MethodVisitor

visitFieldInsn

public void visitFieldInsn(int opcode,
                           String owner,
                           String name,
                           String desc)
Specified by:
visitFieldInsn in interface org.objectweb.asm.MethodVisitor

visitMethodInsn

public void visitMethodInsn(int opcode,
                            String owner,
                            String name,
                            String desc)
Specified by:
visitMethodInsn in interface org.objectweb.asm.MethodVisitor

visitJumpInsn

public void visitJumpInsn(int opcode,
                          org.objectweb.asm.Label label)
Specified by:
visitJumpInsn in interface org.objectweb.asm.MethodVisitor

visitLdcInsn

public void visitLdcInsn(Object cst)
Specified by:
visitLdcInsn in interface org.objectweb.asm.MethodVisitor

visitIincInsn

public void visitIincInsn(int var,
                          int increment)
Specified by:
visitIincInsn in interface org.objectweb.asm.MethodVisitor

visitTableSwitchInsn

public void visitTableSwitchInsn(int min,
                                 int max,
                                 org.objectweb.asm.Label dflt,
                                 org.objectweb.asm.Label[] labels)
Specified by:
visitTableSwitchInsn in interface org.objectweb.asm.MethodVisitor

visitLookupSwitchInsn

public void visitLookupSwitchInsn(org.objectweb.asm.Label dflt,
                                  int[] keys,
                                  org.objectweb.asm.Label[] labels)
Specified by:
visitLookupSwitchInsn in interface org.objectweb.asm.MethodVisitor

visitMultiANewArrayInsn

public void visitMultiANewArrayInsn(String desc,
                                    int dims)
Specified by:
visitMultiANewArrayInsn in interface org.objectweb.asm.MethodVisitor

visitTryCatchBlock

public void visitTryCatchBlock(org.objectweb.asm.Label start,
                               org.objectweb.asm.Label end,
                               org.objectweb.asm.Label handler,
                               String type)
Specified by:
visitTryCatchBlock in interface org.objectweb.asm.MethodVisitor

visitProbe

public void visitProbe(int probeId)
Description copied from interface: IMethodProbesVisitor
Visits an unconditional probe that should be inserted at the current position.

Specified by:
visitProbe in interface IMethodProbesVisitor
Parameters:
probeId - id of the probe to insert

visitJumpInsnWithProbe

public void visitJumpInsnWithProbe(int opcode,
                                   org.objectweb.asm.Label label,
                                   int probeId)
Description copied from interface: IMethodProbesVisitor
Visits 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.

Specified by:
visitJumpInsnWithProbe in interface IMethodProbesVisitor
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 probe
See Also:
MethodVisitor.visitJumpInsn(int, Label)

visitInsnWithProbe

public void visitInsnWithProbe(int opcode,
                               int probeId)
Description copied from interface: IMethodProbesVisitor
Visits 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.

Specified by:
visitInsnWithProbe in interface IMethodProbesVisitor
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)
Description copied from interface: IMethodProbesVisitor
Visits 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 with LabelInfo.getProbeId(Label).

Specified by:
visitTableSwitchInsnWithProbes in interface IMethodProbesVisitor
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 the min + i key.
See Also:
MethodVisitor.visitTableSwitchInsn(int, int, Label, Label[])

visitLookupSwitchInsnWithProbes

public void visitLookupSwitchInsnWithProbes(org.objectweb.asm.Label dflt,
                                            int[] keys,
                                            org.objectweb.asm.Label[] labels)
Description copied from interface: IMethodProbesVisitor
Visits 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 with LabelInfo.getProbeId(Label).

Specified by:
visitLookupSwitchInsnWithProbes in interface IMethodProbesVisitor
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 the keys[i] key.
See Also:
MethodVisitor.visitLookupSwitchInsn(Label, int[], Label[])

visitEnd

public void visitEnd()
Specified by:
visitEnd in interface org.objectweb.asm.MethodVisitor

visitAnnotationDefault

public org.objectweb.asm.AnnotationVisitor visitAnnotationDefault()
Specified by:
visitAnnotationDefault in interface org.objectweb.asm.MethodVisitor

visitAnnotation

public org.objectweb.asm.AnnotationVisitor visitAnnotation(String desc,
                                                           boolean visible)
Specified by:
visitAnnotation in interface org.objectweb.asm.MethodVisitor

visitParameterAnnotation

public org.objectweb.asm.AnnotationVisitor visitParameterAnnotation(int parameter,
                                                                    String desc,
                                                                    boolean visible)
Specified by:
visitParameterAnnotation in interface org.objectweb.asm.MethodVisitor

visitAttribute

public void visitAttribute(org.objectweb.asm.Attribute attr)
Specified by:
visitAttribute in interface org.objectweb.asm.MethodVisitor

visitCode

public void visitCode()
Specified by:
visitCode in interface org.objectweb.asm.MethodVisitor

visitFrame

public void visitFrame(int type,
                       int nLocal,
                       Object[] local,
                       int nStack,
                       Object[] stack)
Specified by:
visitFrame in interface org.objectweb.asm.MethodVisitor

visitLocalVariable

public void visitLocalVariable(String name,
                               String desc,
                               String signature,
                               org.objectweb.asm.Label start,
                               org.objectweb.asm.Label end,
                               int index)
Specified by:
visitLocalVariable in interface org.objectweb.asm.MethodVisitor

visitMaxs

public void visitMaxs(int maxStack,
                      int maxLocals)
Specified by:
visitMaxs in interface org.objectweb.asm.MethodVisitor


Copyright © 2009-2011 Mountainminds GmbH & Co. KG. All Rights Reserved.