Skip to content

Commit a576f3f

Browse files
authored
Merge pull request github#2966 from aschackmull/java/nullness-fp-test
Java: Document a FP for nullness in a test.
2 parents c2db3d7 + 4601639 commit a576f3f

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,4 +208,16 @@ public void ex14(int[] a) {
208208
}
209209
}
210210
}
211+
212+
public void ex15(Object o1, Object o2) {
213+
if (o1 == null && o2 != null) {
214+
return;
215+
}
216+
if (o1 == o2) {
217+
return;
218+
}
219+
if (o1.equals(o2)) { // NPE - false positive
220+
return;
221+
}
222+
}
211223
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,6 @@
3030
| C.java:144:15:144:15 | a | Variable $@ may be null here as suggested by $@ null guard. | C.java:141:20:141:26 | a | a | C.java:142:13:142:21 | ... == ... | this |
3131
| C.java:188:9:188:11 | obj | Variable $@ may be null here because of $@ assignment. | C.java:181:5:181:22 | Object obj | obj | C.java:181:12:181:21 | obj | this |
3232
| C.java:207:9:207:11 | obj | Variable $@ may be null here because of $@ assignment. | C.java:201:5:201:22 | Object obj | obj | C.java:201:12:201:21 | obj | this |
33+
| C.java:219:9:219:10 | o1 | Variable $@ may be null here as suggested by $@ null guard. | C.java:212:20:212:28 | o1 | o1 | C.java:213:9:213:18 | ... == ... | this |
3334
| F.java:11:5:11:7 | obj | Variable $@ may be null here as suggested by $@ null guard. | F.java:8:18:8:27 | obj | obj | F.java:9:9:9:19 | ... == ... | this |
3435
| F.java:17:5:17:7 | obj | Variable $@ may be null here as suggested by $@ null guard. | F.java:14:18:14:27 | obj | obj | F.java:15:9:15:19 | ... == ... | this |

0 commit comments

Comments
 (0)