private boolean isExpectedParmInstruction(int seen, int parmOffset, Type type) { switch (getExpectedReturnInstruction(type)) { case Const.ARETURN: return isExpectedParmInstruction(Const.ALOAD_0, Const.ALOAD, seen, parmOffset); case Const.DRETURN: return isExpectedParmInstruction(Const.DLOAD_0, Const.DLOAD, seen, parmOffset); case Const.FRETURN: return isExpectedParmInstruction(Const.FLOAD_0, Const.FLOAD, seen, parmOffset); case Const.LRETURN: return isExpectedParmInstruction(Const.LLOAD_0, Const.LLOAD, seen, parmOffset); default: return isExpectedParmInstruction(Const.ILOAD_0, Const.ILOAD, seen, parmOffset); } }
private boolean isExpectedParmInstruction(int offsetConstant, int constant, int seen, int parmOffset) { if (parmOffset <= 3) { return (offsetConstant + parmOffset) == seen; } return (constant == seen) && (parmOffset == getRegisterOperand()); }
if (isExpectedParmInstruction(seen, nextParmOffset, parmTypes[nextParmIndex])) { nextParmOffset += SignatureUtils.getSignatureSize(parmTypes[nextParmIndex].getSignature()); nextParmIndex++; if ((seen == Const.INVOKESPECIAL) && getNameConstantOperand().equals(getMethod().getName()) && getSigConstantOperand().equals(getMethod().getSignature())) { sawParentCall = true; } else { int expectedInstruction = getExpectedReturnInstruction(getMethod().getReturnType()); if ((seen == expectedInstruction) && (getNextPC() == getCode().getCode().length)) { bugReporter.reportBug( new BugInstance(this, BugType.COM_PARENT_DELEGATED_CALL.name(), NORMAL_PRIORITY).addClass(this).addMethod(this).addSourceLine(this));
public void visitCode(Code obj) { try { Method m = getMethod(); if ((!m.isPublic() && !m.isProtected()) || m.isAbstract() || m.isSynthetic()) { return; 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;
if (isExpectedParmInstruction(seen, nextParmOffset, parmTypes[nextParmIndex])) { nextParmOffset += SignatureUtils.getSignatureSize(parmTypes[nextParmIndex].getSignature()); nextParmIndex++; if ((seen == INVOKESPECIAL) && getNameConstantOperand().equals(getMethod().getName()) && getSigConstantOperand().equals(getMethod().getSignature())) { sawParentCall = true; } else { int expectedInstruction = getExpectedReturnInstruction(getMethod().getReturnType()); if ((seen == expectedInstruction) && (getNextPC() == getCode().getCode().length)) { bugReporter.reportBug( new BugInstance(this, BugType.COM_PARENT_DELEGATED_CALL.name(), NORMAL_PRIORITY).addClass(this).addMethod(this).addSourceLine(this));
public void visitCode(Code obj) { try { Method m = getMethod(); if ((!m.isPublic() && !m.isProtected()) || m.isAbstract() || m.isSynthetic()) { return; 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() & ACC_SYNCHRONIZED) != (superCode.getAccess() & ACC_SYNCHRONIZED)) { return; parmTypes = getMethod().getArgumentTypes(); nextParmIndex = 0; nextParmOffset = getMethod().isStatic() ? 0 : 1; sawAload0 = nextParmOffset == 0; sawParentCall = false;
private boolean isExpectedParmInstruction(int seen, int parmOffset, Type type) { switch (getExpectedReturnInstruction(type)) { case Constants.ARETURN: return isExpectedParmInstruction(Constants.ALOAD_0, Constants.ALOAD, seen, parmOffset); case Constants.DRETURN: return isExpectedParmInstruction(Constants.DLOAD_0, Constants.DLOAD, seen, parmOffset); case Constants.FRETURN: return isExpectedParmInstruction(Constants.FLOAD_0, Constants.FLOAD, seen, parmOffset); case Constants.LRETURN: return isExpectedParmInstruction(Constants.LLOAD_0, Constants.LLOAD, seen, parmOffset); default: return isExpectedParmInstruction(Constants.ILOAD_0, Constants.ILOAD, seen, parmOffset); } }
private boolean isExpectedParmInstruction(int offsetConstant, int constant, int seen, int parmOffset) { if (parmOffset <= 3) { return (offsetConstant + parmOffset) == seen; } return (constant == seen) && (parmOffset == getRegisterOperand()); }