Class SwitchFallthrough

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

public class SwitchFallthrough extends OpcodeStackDetector implements StatelessDetector
  • Field Details

    • DEBUG

      private static final boolean DEBUG
    • LOOK_IN_SOURCE_FOR_FALLTHRU_COMMENT

      private static final boolean LOOK_IN_SOURCE_FOR_FALLTHRU_COMMENT
    • switchHdlr

      private SwitchHandler switchHdlr
    • reachable

      private boolean reachable
    • bugAccumulator

      private final BugAccumulator bugAccumulator
    • lastPC

      private int lastPC
    • biggestJumpTarget

      private int biggestJumpTarget
    • potentiallyDeadStores

      private final BitSet potentiallyDeadStores
    • potentiallyDeadFields

      private final Set<XField> potentiallyDeadFields
    • potentiallyDeadStoresFromBeforeFallthrough

      private BitSet potentiallyDeadStoresFromBeforeFallthrough
    • potentiallyDeadFieldsFromBeforeFallthrough

      private Set<XField> potentiallyDeadFieldsFromBeforeFallthrough
    • deadStore

      private LocalVariableAnnotation deadStore
    • priority

      private int priority
    • found

    • enumType

      XClass enumType
    • justSawHashcode

      boolean justSawHashcode
  • 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
    • foundSwitchNoDefault

      private void foundSwitchNoDefault(SourceLineAnnotation s)
    • 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)
    • clearAllDeadStores

      private void clearAllDeadStores()
    • hasFallThruComment

      private boolean hasFallThruComment(int startPC, int endPC)