overrides the visitor to find code blocks of methods that are the same as its parents

@param obj
the code object of the currently parsed method
973432
@Override
    public void visitCode(Code obj) {
        try {
            Method m = getMethod();
            if ((!m.isPublic() && !m.isProtected()) || m.isAbstract() || m.isSynthetic()) {
                return;
            }

            CodeInfo superCode = superclassCode.remove(curMethodInfo);
            if (superCode != null) {
                if (sameAccess(getMethod().getAccessFlags(), superCode.getAccess()) && codeEquals(obj, superCode.getCode())) {
                    bugReporter.reportBug(new BugInstance(this, BugType.COM_COPIED_OVERRIDDEN_METHOD.name(), NORMAL_PRIORITY).addClass(this).addMethod(this)
                            .addSourceLine(classContext, this, getPC()));
                    return;
                }

                if ((getMethod().getAccessFlags() & Const.ACC_SYNCHRONIZED) != (superCode.getAccess() & Const.ACC_SYNCHRONIZED)) {
                    return;
                }

                parmTypes = getMethod().getArgumentTypes();
                nextParmIndex = 0;
                nextParmOffset = getMethod().isStatic() ? 0 : 1;
                sawAload0 = nextParmOffset == 0;
                sawParentCall = false;
                super.visitCode(obj);
            }
        } catch (StopOpcodeParsingException e) {
            // method is unique
        }

    }
966689
@Override
    public void visitCode(Code obj) {
        Method method = getMethod();

        if (method.isSynthetic()) {
            return;
        }

        declaredCheckedExceptions.clear();
        stack.resetForMethodEntry(this);

        ExceptionTable et = method.getExceptionTable();
        if (et != null) {
            if (classIsFinal || classIsAnonymous || method.isStatic() || method.isPrivate() || method.isFinal()
                    || ((Values.CONSTRUCTOR.equals(method.getName()) && !isAnonymousInnerCtor(method, getThisClass())))) {
                String[] exNames = et.getExceptionNames();
                for (String exName : exNames) {
                    try {
                        JavaClass exCls = Repository.lookupClass(exName);
                        if (!exCls.instanceOf(runtimeExceptionClass)) {
                            declaredCheckedExceptions.add(exName);
                        }
                    } catch (ClassNotFoundException cnfe) {
                        bugReporter.reportMissingClass(cnfe);
                    }
                }
                if (!declaredCheckedExceptions.isEmpty()) {
                    try {
                        super.visitCode(obj);
                        if (!declaredCheckedExceptions.isEmpty()) {
                            BugInstance bi = new BugInstance(this, BugType.BED_BOGUS_EXCEPTION_DECLARATION.name(), NORMAL_PRIORITY).addClass(this)
                                    .addMethod(this).addSourceLine(this, 0);
                            for (String ex : declaredCheckedExceptions) {
                                bi.addString(ex.replaceAll("/", "."));
                            }
                            bugReporter.reportBug(bi);
                        }
                    } catch (StopOpcodeParsingException e) {
                        // no exceptions left
                    }
                }
            }

            String[] exNames = et.getExceptionNames();
            for (int i = 0; i < (exNames.length - 1); i++) {
                try {
                    JavaClass exCls1 = Repository.lookupClass(exNames[i]);
                    for (int j = i + 1; j < exNames.length; j++) {
                        JavaClass exCls2 = Repository.lookupClass(exNames[j]);
                        JavaClass childEx;
                        JavaClass parentEx;
                        if (exCls1.instanceOf(exCls2)) {
                            childEx = exCls1;
                            parentEx = exCls2;
                        } else if (exCls2.instanceOf(exCls1)) {
                            childEx = exCls2;
                            parentEx = exCls1;
                        } else {
                            continue;
                        }

                        if (!parentEx.equals(exceptionClass)) {
                            bugReporter.reportBug(new BugInstance(this, BugType.BED_HIERARCHICAL_EXCEPTION_DECLARATION.name(), NORMAL_PRIORITY).addClass(this)
                                    .addMethod(this).addString(childEx.getClassName() + " derives from " + parentEx.getClassName()));
                            return;
                        }

                    }
                } catch (ClassNotFoundException cnfe) {
                    bugReporter.reportMissingClass(cnfe);
                }
            }
        }
    }
469678
@Override
    public void visitCode(Code obj) {
        Method m = getMethod();
        String sig = m.getSignature();
        if (!Values.SIG_VOID.equals(SignatureUtils.getReturnSignature(sig))) {
            state = State.SEEN_NOTHING;
            branchTargets.clear();
            CodeException[] ces = obj.getExceptionTable();
            catchTargets.clear();
            stack.resetForMethodEntry(this);
            for (CodeException ce : ces) {
                if (ce.getCatchType() != 0) {
                    catchTargets.set(ce.getHandlerPC());
                }
            }
            super.visitCode(obj);
        }
    }
773962
@Override
    public void visitCode(Code obj) {

        try {
            XMethod xMethod = getXMethod();
            if (xMethod != null) {
                String[] tes = xMethod.getThrownExceptions();
                Set<String> thrownExceptions = new HashSet<>(Arrays.<String> asList((tes == null) ? new String[0] : tes));

                blocks = new ArrayList<>();
                inBlocks = new ArrayList<>();
                transitionPoints = new BitSet();

                CodeException[] ces = obj.getExceptionTable();
                for (CodeException ce : ces) {
                    TryBlock tb = new TryBlock(ce);
                    int existingBlock = blocks.indexOf(tb);
                    if (existingBlock >= 0) {
                        tb = blocks.get(existingBlock);
                        tb.addCatchType(ce);
                    } else {
                        blocks.add(tb);
                    }
                }

                Iterator<TryBlock> it = blocks.iterator();
                while (it.hasNext()) {
                    TryBlock block = it.next();
                    if (block.hasMultipleHandlers() || block.isFinally() || block.catchIsThrown(getConstantPool(), thrownExceptions)) {
                        it.remove();
                    }
                }

                if (blocks.size() > 1) {
                    stack.resetForMethodEntry(this);
                    super.visitCode(obj);

                    if (blocks.size() > 1) {

                        TryBlock firstBlock = blocks.get(0);
                        for (int i = 1; i < blocks.size(); i++) {
                            TryBlock secondBlock = blocks.get(i);

                            if (!blocksSplitAcrossTransitions(firstBlock, secondBlock) && (firstBlock.getCatchType() == secondBlock.getCatchType())
                                    && firstBlock.getThrowSignature().equals(secondBlock.getThrowSignature())
                                    && firstBlock.getMessage().equals(secondBlock.getMessage())
                                    && firstBlock.getExceptionSignature().equals(secondBlock.getExceptionSignature())) {
                                bugReporter.reportBug(new BugInstance(this, BugType.STB_STACKED_TRY_BLOCKS.name(), NORMAL_PRIORITY).addClass(this)
                                        .addMethod(this).addSourceLineRange(this, firstBlock.getStartPC(), firstBlock.getEndHandlerPC())
                                        .addSourceLineRange(this, secondBlock.getStartPC(), secondBlock.getEndHandlerPC()));
                            }

                            firstBlock = secondBlock;
                        }
                    }
                }
            }
        } finally {
            blocks = null;
            inBlocks = null;
            transitionPoints = null;
        }
    }
246601
@Override
    public void visitCode(Code obj) {
        state = State.SEEN_NOTHING;
        beanReference1 = null;
        beanReference2 = null;
        propName = null;
        propType = null;
        sawField = false;
        super.visitCode(obj);
    }
92549
@Override
    public void visitCode(Code obj) {
        Method m = getMethod();
        stack.resetForMethodEntry(this);
        initializedRegs.clear();
        modifyRegs.clear();
        Type[] argTypes = m.getArgumentTypes();
        int arg = m.isStatic() ? 0 : 1;
        for (Type argType : argTypes) {
            String argSig = argType.getSignature();
            initializedRegs.set(arg);
            arg += SignatureUtils.getSignatureSize(argSig);
        }
        nullStoreToLocation.clear();
        super.visitCode(obj);

        for (Integer pc : nullStoreToLocation.values()) {
            bugReporter.reportBug(new BugInstance(this, BugType.AIOB_ARRAY_STORE_TO_NULL_REFERENCE.name(), HIGH_PRIORITY).addClass(this).addMethod(this)
                    .addSourceLine(this, pc.intValue()));
        }
    }
178784
@Override
    public void visitCode(Code obj) {
        try {
            String signature = SignatureUtils.getReturnSignature(getMethod().getSignature());
            if (signature.startsWith(Values.SIG_QUALIFIED_CLASS_PREFIX) && CollectionUtils.isListSetMap(SignatureUtils.stripSignature(signature))) {
                stack.resetForMethodEntry(this);
                imType = ImmutabilityType.UNKNOWN;

                super.visitCode(obj);

                if ((imType == ImmutabilityType.IMMUTABLE) || (imType == ImmutabilityType.POSSIBLY_IMMUTABLE)) {
                    Method m = getMethod();
                    Statistics.getStatistics().addImmutabilityStatus(clsName, m.getName(), m.getSignature(), imType);
                }
            }
        } catch (ClassNotFoundException cnfe) {
            bugReporter.reportMissingClass(cnfe);
        }
    }
1319440
@Override
    public void visitCode(Code obj) {
        try {
            Method m = getMethod();
            Type retType = m.getReturnType();
            if ("Ljava/lang/Boolean;".equals(retType.getSignature())) {
                stack.resetForMethodEntry(this);
                super.visitCode(obj);
            }
        } catch (StopOpcodeParsingException e) {
            // if the method was already reported
        }
    }
582635
@Override
    public void visitCode(Code obj) {
        Method method = getMethod();
        if (prescreen(method)) {
            stack.resetForMethodEntry(this);
            regPriorities.clear();
            int[] parmRegs = RegisterUtils.getParameterRegisters(method);
            for (int reg : parmRegs) {
                regPriorities.put(Integer.valueOf(reg), Values.NORMAL_BUG_PRIORITY);
            }
            if (!method.isStatic()) {
                regPriorities.put(Values.ZERO, Values.LOW_BUG_PRIORITY);
            }
            super.visitCode(obj);
        }
    }
31620
@Override
    public void visitMethod(Method obj) {
        suspectLocals.clear();
        int[] parmRegs = RegisterUtils.getParameterRegisters(obj);
        for (int pr : parmRegs) {
            suspectLocals.put(Integer.valueOf(pr), new RegisterInfo(RegisterUtils.getLocalVariableEndRange(obj.getLocalVariableTable(), pr, 0)));
        }
    }
1067690
@Override
    public void visitCode(Code obj) {
        stack.resetForMethodEntry(this);
        activeStackOps.clear();
        super.visitCode(obj);
    }
828688
@Override
    public void visitCode(Code obj) {
        unusedParms.clear();
        regToParm.clear();
        stack.resetForMethodEntry(this);
        Method m = getMethod();
        String methodName = m.getName();
        if (IGNORE_METHODS.contains(methodName)) {
            return;
        }

        int accessFlags = m.getAccessFlags();
        if (((accessFlags & (Const.ACC_STATIC | Const.ACC_PRIVATE)) == 0) || ((accessFlags & Const.ACC_SYNTHETIC) != 0)) {
            return;
        }

        List<String> parmTypes = SignatureUtils.getParameterSignatures(m.getSignature());

        if (parmTypes.isEmpty()) {
            return;
        }
        int firstReg = 0;
        if ((accessFlags & Const.ACC_STATIC) == 0) {
            ++firstReg;
        }

        int reg = firstReg;
        for (int i = 0; i < parmTypes.size(); ++i) {
            unusedParms.set(reg);
            regToParm.put(Integer.valueOf(reg), Integer.valueOf(i + 1));
            String parmSig = parmTypes.get(i);
            reg += SignatureUtils.getSignatureSize(parmSig);
        }

        try {
            super.visitCode(obj);

            if (!unusedParms.isEmpty()) {
                LocalVariableTable lvt = m.getLocalVariableTable();

                reg = unusedParms.nextSetBit(firstReg);
                while (reg >= 0) {
                    LocalVariable lv = (lvt == null) ? null : lvt.getLocalVariable(reg, 0);
                    if (lv != null) {
                        String parmName = lv.getName();
                        bugReporter.reportBug(new BugInstance(this, BugType.UP_UNUSED_PARAMETER.name(), NORMAL_PRIORITY).addClass(this).addMethod(this)
                                .addString("Parameter " + regToParm.get(Integer.valueOf(reg)) + ": " + parmName));
                    }
                    reg = unusedParms.nextSetBit(reg + 1);
                }
            }
        } catch (StopOpcodeParsingException e) {
            // no unusedParms left
        }
    }
831968
@Override
    public void visitMethod(Method obj) {
        methodName = obj.getName();
        state = State.SAW_NOTHING;
    }
267215
@Override
    public void visitCode(Code obj) {
        stack.resetForMethodEntry(this);
        nextAllocNumber = 1;
        storeToUserValue.clear();
        allocLocation.clear();
        allocToAddPCs.clear();
        optionalRanges.clear();

        addExceptionRanges(obj);

        super.visitCode(obj);

        for (List<Integer> pcs : allocToAddPCs.values()) {
            if (pcs.size() > 16) {
                bugReporter.reportBug(new BugInstance(this, BugType.PSC_PRESIZE_COLLECTIONS.name(), NORMAL_PRIORITY).addClass(this).addMethod(this)
                        .addSourceLine(this, pcs.get(0).intValue()));
            }
        }
    }
558979
@Override
    public void visitCode(Code obj) {
        Method m = getMethod();
        if (prescreen(m)) {
            stack.resetForMethodEntry(this);
            popStack.clear();
            super.visitCode(obj);
        }
    }
746546
@Override
    public void visitCode(Code obj) {

        stack.resetForMethodEntry(this);
        unendedZLIBs.clear();
        super.visitCode(obj);

        for (SourceLineAnnotation sa : unendedZLIBs.values()) {
            bugReporter.reportBug(new BugInstance(this, BugType.IOI_UNENDED_ZLIB_OBJECT.name(), NORMAL_PRIORITY)
                    .addClass(this).addMethod(this).addSourceLine(sa));
        }
    }
363063
public void executeBeforeMethods(final Object obj) {
        // Invoke element only if not parameterized
        if (this.element.getDataProvider() == null) {
            // invoking once the beforeFirstRun-method
            if (!beforeFirstRun) {
                beforeFirstRun = true;

                Method[] beforeFirst = null;
                try {
                    beforeFirst = element.findBeforeFirstRun();
                    if (beforeFirst.length != 0) {
                        checkAndExecuteBeforeAfters(obj, BeforeFirstRun.class, beforeFirst);
                    }
                } catch (final PerfidixMethodCheckException e) {
                    BENCHRES.addException(e);
                }
            }

            // invoking the beforeEachRun-method
            Method[] beforeEach = null;
            try {
                beforeEach = element.findBeforeEachRun();
                if (beforeEach.length != 0) {
                    checkAndExecuteBeforeAfters(obj, BeforeEachRun.class, beforeEach);
                }
            } catch (final PerfidixMethodCheckException e) {
                BENCHRES.addException(e);
            }
        }
    }