// ins.getName() + "\t" + frame);
ALOAD load = (ALOAD) ins;
int index = load.getIndex();
IsNullValue v = frame.getValue(index);
if (!v.isDefinitelyNull()) {
int sourceLine = lineNumbers.getSourceLine(handle.getPosition());
if (sourceLine > 0) {
linesWithLoadsOfNotDefinitelyNullValues.set(sourceLine);
}
}
}
}
IdentityHashMap<InstructionHandle, Object> sometimesGood = new IdentityHashMap<InstructionHandle, Object>();
for (Iterator<Location> i = cfg.locationIterator(); i.hasNext();) {
Location location = i.next();
InstructionHandle handle = location.getHandle();
Instruction ins = handle.getInstruction();
if (!(ins instanceof ALOAD)) {
continue;
}
IsNullValueFrame frame = nullValueDataflow.getFactAtLocation(location);
if (!frame.isValid()) {
// This basic block is probably dead
continue;
}
// System.out.println(handle.getPosition() + "\t" + ins.getName() +
// "\t" + frame);
ALOAD load = (ALOAD) ins;
int index = load.getIndex();
IsNullValue v = frame.getValue(index);
if (!v.isDefinitelyNull()) {
sometimesGood.put(handle, null);
}
}
// System.out.println(nullValueDataflow);
for (Iterator<Location> i = cfg.locationIterator(); i.hasNext();) {
Location location = i.next();
InstructionHandle handle = location.getHandle();
Instruction ins = handle.getInstruction();
if (!(ins instanceof ALOAD)) {
continue;
}
if (sometimesGood.containsKey(handle)) {
continue;
}
IsNullValueFrame frame = nullValueDataflow.getFactAtLocation(location);
if (!frame.isValid()) {
// This basic block is probably dead
continue;
}
// System.out.println(handle.getPosition() + "\t" + ins.getName() +
// "\t" + frame);
ALOAD load = (ALOAD) ins;
int index = load.getIndex();
IsNullValue v = frame.getValue(index);
if (v.isDefinitelyNull()) {
InstructionHandle nextHandle = handle.getNext();
Instruction next = nextHandle.getInstruction();
int position = location
.getHandle().getPosition();
int catchSizeANY = Util.getSizeOfSurroundingTryBlock(method, "", position);
if (catchSizeANY < Integer.MAX_VALUE && isNullTestedClose( classContext, load, nextHandle, next)) {
continue;
}
InstructionHandle prevHandle = handle.getPrev();
SourceLineAnnotation sourceLineAnnotation = SourceLineAnnotation.fromVisitedInstruction(classContext, methodGen,
sourceFile, handle);
SourceLineAnnotation prevSourceLineAnnotation = SourceLineAnnotation.fromVisitedInstruction(classContext,
methodGen, sourceFile, prevHandle);
if (next instanceof ARETURN) {
// probably stored for duration of finally block
continue;
}
if (next instanceof GOTO) {
InstructionHandle targ = ((BranchInstruction) next).getTarget();
if (targ.getInstruction() instanceof ARETURN) {
// Skip for the same reason we would skip if
// (next instanceof ARETURN) were true. This
// is necessary because the bytecode compiler
// compiles the ternary ? operator with a GOTO
// to an ARETURN instead of just an ARETURN.
continue;
}
}
int startLine = sourceLineAnnotation.getStartLine();
if (startLine > 0 && lineMentionedMultipleTimes.get(startLine)
&& linesWithLoadsOfNotDefinitelyNullValues.get(startLine)) {
continue;
}
int previousLine = prevSourceLineAnnotation.getEndLine();
if (startLine < previousLine) {
// probably stored for duration of finally block
// System.out.println("Inverted line");
continue;
}
int priority = NORMAL_PRIORITY;
if (!v.isChecked()) {
priority++;
}
BugAnnotation variableAnnotation = null;
try {