Class SwitchFallthrough

All Implemented Interfaces:
Detector, Priorities, StatelessDetector, Cloneable, org.apache.bcel.classfile.Visitor

public class SwitchFallthrough extends OpcodeStackDetector implements StatelessDetector
  • Constructor Details

    • SwitchFallthrough

      public SwitchFallthrough(BugReporter bugReporter)
  • Method Details

    • visitClassContext

      public void visitClassContext(ClassContext classContext)
      Description copied from interface: Detector
      Visit the ClassContext for a class which should be analyzed for instances of bug patterns.
      Specified by:
      visitClassContext in interface Detector
      Overrides:
      visitClassContext in class BytecodeScanningDetector
      Parameters:
      classContext - the ClassContext
    • visit

      public void visit(org.apache.bcel.classfile.Code obj)
      Overrides:
      visit in class DismantleBytecode
    • sawOpcode

      public void sawOpcode(int seen)
      Description copied from class: OpcodeStackDetector

      By default, this method will not be called when stack is TOP. To change this behavior, override #beforeOpcode(int) and change to return true even if stack is TOP.

      see Using FindBugs for Research to learn lattice and what TOP means.

      Specified by:
      sawOpcode in class OpcodeStackDetector
      See Also:
    • isBranchTargetOutsideOfNextCase

      public boolean isBranchTargetOutsideOfNextCase()
      A GOTO might correspond to a break or to a do/while/for loop. For loops the branch target will be before the offset of the next case, for breaks we're exiting the switch so the target is actually even after the end of the last case. The branch target might be before the switch when we're inside another structure such as a loop.
      Returns:
      true if:
      • the branch target is a GOTO instruction as it is the case for a no-op (empty block) in an arrow-syntax switch
      • the branch target is after the next switch offset as it is the case for a switch break
      • or the branch target is before the PC corresponding to the switch instruction
      • or there's no next switch case (as it is the case for the default case)