Java: Add more nullness tests and fix a bug causing false negatives.#20267
Merged
aschackmull merged 6 commits intogithub:mainfrom Aug 25, 2025
Merged
Java: Add more nullness tests and fix a bug causing false negatives.#20267aschackmull merged 6 commits intogithub:mainfrom
aschackmull merged 6 commits intogithub:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR adds enhanced test coverage for nullness analysis control flow scenarios and fixes a subtle bug causing false negatives in nullness detection. The changes include additional complex loop and correlation tests that expose edge cases in control flow analysis, plus a fix to a boolean logic error in the tracking variable guard implementation.
- Adds comprehensive test cases for complex loop scenarios and variable tracking edge cases
- Fixes a boolean logic bug in
trackingVarGuardthat was causing false negatives - Enhances Guards library to recognize non-null catch clause exception variables
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| B.java | Adds new test methods covering complex loop scenarios, variable correlation, and edge cases for nullness analysis |
| NullMaybe.expected | Updates expected test results to include new nullness warnings from the added test cases |
| Nullness.qll | Fixes boolean logic bug in trackingVarGuard by removing incorrect .booleanNot() call |
| Guards.qll | Adds logic to recognize catch clause exception variables as non-null |
hvitved
previously approved these changes
Aug 22, 2025
Contributor
Author
|
Dca looks good - several repos have one or two instances of this, so adding a change note. |
hvitved
approved these changes
Aug 25, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This adds a number of additional tricky control-flow tests, which are useful in my work on control-flow reachability.
I've also uncovered a subtle bug in nullness, which I've fixed and documented with a test.
Finally, a drive-by improvement to Java Guards teaching it about the non-nullness of catch-clause declared exception variables (this is already known by the current nullness library, but there it relies on full SSA, which is why this case didn't originally make it into the Guards instantiation).