Class FindUselessControlFlow

All Implemented Interfaces:
Detector, Priorities, StatelessDetector, 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 Details

    • FindUselessControlFlow

      public FindUselessControlFlow(BugReporter bugReporter)
  • Method Details

    • visit

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

      public void sawOpcode(int seen)
      Overrides:
      sawOpcode in class DismantleBytecode
    • getNextSourceLine

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