Skip to content

Commit 9fc0793

Browse files
committed
Java: More nullness qltests, including highlight of FN bug.
1 parent 1c72437 commit 9fc0793

File tree

1 file changed

+19
-0
lines changed
  • java/ql/test/query-tests/Nullness

1 file changed

+19
-0
lines changed

java/ql/test/query-tests/Nullness/B.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -496,4 +496,23 @@ public void initCorr(boolean b) {
496496
else
497497
o2.hashCode(); // OK
498498
}
499+
500+
public void complexLoopTest(int[] xs, int[] ys) {
501+
int len = ys != null ? ys.length : 0;
502+
for (int i = 0, j = 0; i < xs.length; i++) {
503+
if (j < len && ys[j] == 42) { // OK
504+
j++;
505+
} else if (j > 0) {
506+
ys[0]++; // OK
507+
}
508+
}
509+
}
510+
511+
public void trackTest(Object o, int n) {
512+
boolean isnull = o == null;
513+
int c = -1;
514+
if (maybe) { }
515+
if (c == 100) { return; }
516+
o.hashCode(); // NPE - false negative
517+
}
499518
}

0 commit comments

Comments
 (0)