Skip to content

Java: Add more nullness tests and fix a bug causing false negatives. #20267

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

aschackmull
Copy link
Contributor

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).

@aschackmull aschackmull requested a review from a team as a code owner August 22, 2025 08:22
@Copilot Copilot AI review requested due to automatic review settings August 22, 2025 08:22
@github-actions github-actions bot added the Java label Aug 22, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 trackingVarGuard that 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
hvitved previously approved these changes Aug 22, 2025
@aschackmull
Copy link
Contributor Author

Dca looks good - several repos have one or two instances of this, so adding a change note.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants