Skip to content

Commit 2192d75

Browse files
committed
Java: Add test for a known FP.
1 parent 0419667 commit 2192d75

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,4 +254,15 @@ public void ex18(boolean b, int[] xs, Object related) {
254254
xs[0] = 42; // OK
255255
}
256256
}
257+
258+
public void ex19(Object t, Object x) {
259+
boolean b = t != null || x != null;
260+
if (b) {
261+
if (t != null) {
262+
t.hashCode(); // OK
263+
} else {
264+
x.hashCode(); // NPE - false positive
265+
}
266+
}
267+
}
257268
}

java/ql/test/query-tests/Nullness/NullMaybe.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
| C.java:144:15:144:15 | a | Variable $@ may be null at this access as suggested by $@ null guard. | C.java:141:20:141:26 | a | a | C.java:142:13:142:21 | ... == ... | this |
3636
| C.java:219:9:219:10 | o1 | Variable $@ may be null at this access as suggested by $@ null guard. | C.java:212:20:212:28 | o1 | o1 | C.java:213:9:213:18 | ... == ... | this |
3737
| C.java:233:7:233:8 | xs | Variable $@ may be null at this access because of $@ assignment. | C.java:231:5:231:56 | int[] xs | xs | C.java:231:11:231:55 | xs | this |
38+
| C.java:264:9:264:9 | x | Variable $@ may be null at this access as suggested by $@ null guard. | C.java:258:30:258:37 | x | x | C.java:259:30:259:38 | ... != ... | this |
3839
| F.java:11:5:11:7 | obj | Variable $@ may be null at this access as suggested by $@ null guard. | F.java:8:18:8:27 | obj | obj | F.java:9:9:9:19 | ... == ... | this |
3940
| F.java:17:5:17:7 | obj | Variable $@ may be null at this access as suggested by $@ null guard. | F.java:14:18:14:27 | obj | obj | F.java:15:9:15:19 | ... == ... | this |
4041
| G.java:20:12:20:12 | s | Variable $@ may be null at this access as suggested by $@ null guard. | G.java:3:27:3:34 | s | s | G.java:5:9:5:17 | ... == ... | this |

0 commit comments

Comments
 (0)