} else {
priority++;
}
}
BugInstance bugInstance = new BugInstance(this, bugType, priority).addClassAndMethod(classContext.getJavaClass(), method);
if (invokedMethod != null) {
assert invokedXMethod != null;
XMethod i = invokedXMethod.resolveAccessMethodForMethod();
if (i != invokedXMethod) {
bugInstance.addMethod(i).describe(MethodAnnotation.METHOD_CALLED);
} else {
bugInstance.addMethod(invokedMethod).describe(MethodAnnotation.METHOD_CALLED)
.addParameterAnnotation(parameterNumber, "INT_MAYBE_NULL_ARG");
}
}
if (storedField != null) {
bugInstance.addField(storedField).describe("FIELD_STORED");
}
bugInstance.addOptionalAnnotation(variableAnnotation);
if (variableAnnotation instanceof FieldAnnotation) {
bugInstance.describe("FIELD_CONTAINS_VALUE");
}
addPropertiesForDereferenceLocations(propertySet, derefLocationSet, false);
if (deref.isAlwaysOnExceptionPath()) {
propertySet.addProperty(NullDerefProperty.ALWAYS_ON_EXCEPTION_PATH);
}
if (!assignedNullLocationSet.isEmpty() && distance > 100) {
propertySet.addProperty(NullDerefProperty.LONG_RANGE_NULL_SOURCE);
}
propertySet.decorateBugInstance(bugInstance);
if (bugType.equals("NP_DEREFERENCE_OF_READLINE_VALUE")) {
int source = -9999;
if (knownNullLocations.size() == 1) {
source = knownNullLocations.iterator().next().getEndBytecode();
}
for (Location loc : derefLocationSet) {
int pos = loc.getHandle().getPosition();
if (pos != source + 3) {
// another detector
bugAccumulator.accumulateBug(bugInstance,
SourceLineAnnotation.fromVisitedInstruction(classContext, method, loc));
}
}
} else {
for (Location loc : derefLocationSet) {
bugInstance.addSourceLine(classContext, method, loc).describe(getDescription(loc, refValue));
}
if (sourceLocations == doomedLocations && assignedNullLocationSet.size() == 1) {
Location assignedNull = assignedNullLocationSet.iterator().next();
SourceLineAnnotation sourceLineAnnotation = SourceLineAnnotation.fromVisitedInstruction(classContext, method,
assignedNull);
if (sourceLineAnnotation != null) {
int startLine = sourceLineAnnotation.getStartLine();
if (startLine > 0 && !knownNull.get(startLine)) {
bugInstance.add(sourceLineAnnotation).describe("SOURCE_LINE_NULL_VALUE");
}
}
}
for (SourceLineAnnotation sourceLineAnnotation : knownNullLocations) {
bugInstance.add(sourceLineAnnotation).describe("SOURCE_LINE_KNOWN_NULL");
}
// Report it
bugReporter.reportBug(bugInstance);
}