OpcodeStack.Item left = stack.getStackItem(1);
OpcodeStack.Item right = stack.getStackItem(0);
if (badUseOfCompareResult(left, right)) {
XMethod returnValueOf = left.getReturnValueOf();
assert returnValueOf != null;
bugAccumulator.accumulateBug(new BugInstance(this, "RV_CHECK_COMPARETO_FOR_SPECIFIC_RETURN_VALUE", NORMAL_PRIORITY)
.addClassAndMethod(this).addMethod(returnValueOf).describe(MethodAnnotation.METHOD_CALLED).addValueSource(right, this), this);
} else if (badUseOfCompareResult(right, left)) {
XMethod returnValueOf = right.getReturnValueOf();
assert returnValueOf != null;
bugAccumulator.accumulateBug(new BugInstance(this, "RV_CHECK_COMPARETO_FOR_SPECIFIC_RETURN_VALUE", NORMAL_PRIORITY)
.addClassAndMethod(this).addMethod(returnValueOf).describe(MethodAnnotation.METHOD_CALLED).addValueSource(left, this), this);
}
break;
default:
break;
}
checkForInitWithoutCopyOnStack: if (seen == INVOKESPECIAL && getNameConstantOperand().equals("<init>")) {
int arguments = PreorderVisitor.getNumberArguments(getSigConstantOperand());
OpcodeStack.Item invokedOn = stack.getStackItem(arguments);
if (invokedOn.isNewlyAllocated() && (!getMethodName().equals("<init>") || invokedOn.getRegisterNumber() != 0)) {
for (int i = arguments + 1; i < stack.getStackDepth(); i++) {
OpcodeStack.Item item = stack.getStackItem(i);
if (item.isNewlyAllocated() && item.getSignature().equals(invokedOn.getSignature())) {
break checkForInitWithoutCopyOnStack;
}
}
callSeen = XFactory.createReferencedXMethod(this);
callPC = getPC();
sawMethodCallWithIgnoredReturnValue();
state = SCAN;
previousOpcodeWasNEW = false;
return;
}
}
if (state == SAW_INVOKE && isPop(seen)) {
sawMethodCallWithIgnoredReturnValue();
} else if (INVOKE_OPCODE_SET.get(seen)) {
callPC = getPC();
callSeen = XFactory.createReferencedXMethod(this);
state = SAW_INVOKE;
if (DEBUG) {
System.out.println(" invoking " + callSeen);
}
} else {
state = SCAN;
}
if (seen == NEW) {
previousOpcodeWasNEW = true;
} else {
if (seen == INVOKESPECIAL && previousOpcodeWasNEW) {
CheckReturnValueAnnotation annotation = checkReturnAnnotationDatabase.getResolvedAnnotation(callSeen, false);
if (annotation != null && annotation != CheckReturnValueAnnotation.CHECK_RETURN_VALUE_IGNORE) {
int priority = annotation.getPriority();
if (!checkReturnAnnotationDatabase.annotationIsDirect(callSeen)
&& !callSeen.getSignature().endsWith(callSeen.getClassName().replace('.', '/') + ";")) {
priority++;
}
bugAccumulator.accumulateBug(new BugInstance(this, annotation.getPattern(), priority).addClassAndMethod(this)
.addCalledMethod(this), this);
}
}
previousOpcodeWasNEW = false;