Class DuplicateBranches

    • Constructor Detail

      • DuplicateBranches

        public DuplicateBranches​(BugReporter bugReporter)
    • Method Detail

      • 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
        Parameters:
        classContext - the ClassContext
      • visitMethod

        public void visitMethod​(org.apache.bcel.classfile.Method method)
        Specified by:
        visitMethod in interface org.apache.bcel.classfile.Visitor
        Overrides:
        visitMethod in class BetterVisitor
      • findIfElseDuplicates

        private void findIfElseDuplicates​(CFG cfg,
                                          org.apache.bcel.classfile.Method method,
                                          BasicBlock bb)
      • getDeepFirstInstruction

        private static org.apache.bcel.generic.InstructionHandle getDeepFirstInstruction​(CFG cfg,
                                                                                         BasicBlock bb)
        Like bb.getFirstInstruction() except that if null is returned it will follow the FALL_THROUGH_EDGE (if any)
      • findSwitchDuplicates

        private void findSwitchDuplicates​(CFG cfg,
                                          org.apache.bcel.classfile.Method method,
                                          BasicBlock bb)
      • updateMap

        private void updateMap​(java.util.HashMap<java.math.BigInteger,​java.util.Collection<java.lang.Integer>> map,
                               int i,
                               java.math.BigInteger clauseAsInt)
      • getCodeBytesAsBigInt

        private java.math.BigInteger getCodeBytesAsBigInt​(org.apache.bcel.classfile.Method method,
                                                          int[] switchPos,
                                                          int i,
                                                          int endPos)
      • getFinalTarget

        private static int getFinalTarget​(CFG cfg,
                                          int myPos,
                                          java.util.Collection<org.apache.bcel.generic.InstructionHandle> prevs)
        determine the end position (exclusive) of the final case by looking at the gotos at the ends of the other cases
      • getCodeBytes

        private byte[] getCodeBytes​(org.apache.bcel.classfile.Method m,
                                    int start,
                                    int end)
      • findThenFinish

        private org.apache.bcel.generic.InstructionHandle findThenFinish​(CFG cfg,
                                                                         BasicBlock thenBB,
                                                                         int elsePos)
      • report

        public void report()
        Description copied from interface: Detector
        This method is called after all classes to be visited. It should be used by any detectors which accumulate information over all visited classes to generate results.
        Specified by:
        report in interface Detector