mirror of
https://github.com/github/codeql.git
synced 2026-04-30 11:15:13 +02:00
Java: Include non-null final fields in clearlyNotNull.
This commit is contained in:
@@ -159,4 +159,13 @@ public class C {
|
||||
obj.hashCode(); // OK
|
||||
}
|
||||
}
|
||||
|
||||
private final Object finalObj = new Object();
|
||||
|
||||
public void ex12() {
|
||||
finalObj.hashCode(); // OK
|
||||
if (finalObj != null) {
|
||||
finalObj.hashCode(); // OK
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,4 +44,13 @@ public class A {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private final Object finalObj = new Object();
|
||||
|
||||
public void ex12() {
|
||||
finalObj.hashCode();
|
||||
if (finalObj != null) { // Useless check
|
||||
finalObj.hashCode();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,3 +5,4 @@
|
||||
| A.java:31:11:31:19 | ... != ... | This check is useless, $@ cannot be null here, since $@ always is non-null. | A.java:31:11:31:11 | x | x | A.java:29:17:29:20 | this | this |
|
||||
| A.java:40:14:40:25 | ... != ... | This check is useless, since $@ always is non-null. | A.java:40:14:40:17 | this | this | A.java:40:14:40:17 | this | this |
|
||||
| A.java:42:9:42:17 | ... != ... | This check is useless, $@ cannot be null here, since it is guarded by $@. | A.java:42:9:42:9 | x | x | A.java:39:9:39:17 | ... == ... | ... == ... |
|
||||
| A.java:52:9:52:24 | ... != ... | This check is useless, $@ cannot be null here, since $@ always is non-null. | A.java:52:9:52:16 | finalObj | finalObj | A.java:48:35:48:46 | new Object(...) | new Object(...) |
|
||||
|
||||
Reference in New Issue
Block a user