Class Replacements

java.lang.Object
org.jacoco.core.internal.analysis.filter.Replacements

public final class Replacements extends Object
Utility for creating an argument for IFilterOutput.replaceBranches(AbstractInsnNode, Replacements) with information about how to compute the coverage status of branches of instruction from the coverage status of branches of other instructions.
  • Field Details

  • Constructor Details

    • Replacements

      public Replacements()
  • Method Details

    • add

      public void add(org.objectweb.asm.tree.AbstractInsnNode target, org.objectweb.asm.tree.AbstractInsnNode instruction, int branchIndex)
      Adds branch which has a given target and which should be considered as covered when a branch with a given index of a given instruction is covered.

      The branch index should be specified in accordance with the ones assigned by MethodAnalyzer to a given instruction:

      • for TableSwitchInsnNode (and similarly for LookupSwitchInsnNode)
        • the branch index corresponds to the indexes in the list of unique labels among TableSwitchInsnNode.dflt and TableSwitchInsnNode.labels
        • there are as many branches as unique labels
        • branch 0 corresponds to continuation of execution at TableSwitchInsnNode.dflt
      • for JumpInsnNode with Opcodes.GOTO there is only branch 1 that corresponds to continuation of execution at JumpInsnNode.label
      • for other JumpInsnNode there are two branches
        • branch 1 corresponds to continuation of execution at JumpInsnNode.label
        • branch 0 corresponds to continuation of execution at AbstractInsnNode.getNext()
      • for instructions with Opcodes.RETURN and Opcodes.ATHROW there is only branch 0 that corresponds to exit from the method
      • there are no branches for instructions whose AbstractInsnNode.getOpcode() is -1
      • for other instructions there is only branch 0 that corresponds to continuation of execution at AbstractInsnNode.getNext()
      Parameters:
      target - instruction uniquely identifying new branch, e.g. its target
      instruction - instruction whose branch execution status should be used
      branchIndex - index of branch whose execution status should be used
    • values

      Returns:
      the accumulated information in the order of additions
    • ignoreDefaultBranch

      static Replacements ignoreDefaultBranch(org.objectweb.asm.tree.AbstractInsnNode switchNode)
      Returns:
      information about how to compute coverage status of branches of a given TableSwitchInsnNode or LookupSwitchInsnNode in order to ignore its TableSwitchInsnNode.dflt or LookupSwitchInsnNode.dflt