Class FindUselessControlFlow

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

    public class FindUselessControlFlow
    extends BytecodeScanningDetector
    implements StatelessDetector

    A Detector to look for useless control flow. For example,

     if (argv.length == 1)
         ;
     System.out.println("Hello, " + argv[0]);
     

    In this kind of bug, we'll see an ifcmp instruction where the IF target is the same as the fall-through target.

    The idea for this detector came from Richard P. King, and the idea of looking for if instructions with identical branch and fall-through targets is from Mike Fagan.

    Author:
    David Hovemeyer
    • Constructor Detail

      • FindUselessControlFlow

        public FindUselessControlFlow​(BugReporter bugReporter)
    • Method Detail

      • visit

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

        public static int getNextSourceLine​(org.apache.bcel.classfile.LineNumberTable lineNumbers,
                                            int sourceLine)