Java: More nullness qltests, including highlight of FN bug.

This commit is contained in:
Anders Schack-Mulligen
2025-08-22 10:12:48 +02:00
parent 1c724372f2
commit 9fc0793d6a

View File

@@ -496,4 +496,23 @@ public class B {
else
o2.hashCode(); // OK
}
public void complexLoopTest(int[] xs, int[] ys) {
int len = ys != null ? ys.length : 0;
for (int i = 0, j = 0; i < xs.length; i++) {
if (j < len && ys[j] == 42) { // OK
j++;
} else if (j > 0) {
ys[0]++; // OK
}
}
}
public void trackTest(Object o, int n) {
boolean isnull = o == null;
int c = -1;
if (maybe) { }
if (c == 100) { return; }
o.hashCode(); // NPE - false negative
}
}