Skip to content

Test requireNonNullElse inference with and without the JSpecify JDK models - #2033

Merged
msridhar merged 1 commit into
apache:masterfrom
vlsi:claude/issue-1493-unignore-test-abfdd6
Oct 23, 2026
Merged

msridhar merged 1 commit into
apache:masterfrom
vlsi:claude/issue-1493-unignore-test-abfdd6

Conversation

@vlsi

@vlsi vlsi commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

With WarnOnGenericInferenceFailure on and no JDK models, returning Objects.requireNonNullElse(nullable, nonNull) from a method with a non-null String return reports inference failure: type variable T constrained to be both @NonNull and @Nullable (#1493). The JSpecify JDK models (#1641, NullAway 0.14.0) declare <T> T requireNonNullElse(@Nullable T obj, @Nullable T defaultObj), so T is inferred as non-null String and nothing is reported. The models are enabled by -XepOpt:NullAway:JSpecifyJDKModels=true, or by -XepOpt:NullAway:JSpecifyExperimental=true, whose value that flag defaults to.

GenericMethodTests.issue1493 was added with @Ignore in #1496 and passes now. This change enables it as issue1493RequireNonNullElseWithJdkModels and adds issue1493RequireNonNullElseWithoutJdkModels, which compiles the same source with JSpecifyJDKModels=false and expects the inference failure. Both tests set WarnOnGenericInferenceFailure=true and JSpecifyJDKModels explicitly instead of taking them from the JSpecifyExperimental default, so the pair differs only in the models flag; with that flag set to true, the second test fails with "There were no errors".

Refs #1493. Merging does not close it: the reporter's configuration without the models (JSpecifyMode plus WarnOnGenericInferenceFailure=true) still reports the warning, and whether the issue can close before the models are on by default is for the maintainers to decide.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Tests
    • Added enabled coverage for Objects.requireNonNullElse generic inference with JSpecify JDK models enabled and disabled.

…odels

With `WarnOnGenericInferenceFailure` on and no JDK models, returning `Objects.requireNonNullElse(nullable, nonNull)` from a method with a non-null `String` return reports `inference failure: type variable T constrained to be both @nonnull and @Nullable` (apache#1493). The JSpecify JDK models (apache#1641, NullAway 0.14.0) declare `<T> T requireNonNullElse(@nullable T obj, @nullable T defaultObj)`, so `T` is inferred as non-null `String` and nothing is reported. The models are enabled by `-XepOpt:NullAway:JSpecifyJDKModels=true`, or by `-XepOpt:NullAway:JSpecifyExperimental=true`, whose value that flag defaults to.

`GenericMethodTests.issue1493` was added with `@Ignore` in apache#1496 and passes now. This change enables it as `issue1493RequireNonNullElseWithJdkModels` and adds `issue1493RequireNonNullElseWithoutJdkModels`, which compiles the same source with `JSpecifyJDKModels=false` and expects the inference failure. Both tests set `WarnOnGenericInferenceFailure=true` and `JSpecifyJDKModels` explicitly instead of taking them from the `JSpecifyExperimental` default, so the pair differs only in the models flag; with that flag set to `true`, the second test fails with "There were no errors".

Refs apache#1493. Merging does not close it: the reporter's configuration without the models (`JSpecifyMode` plus `WarnOnGenericInferenceFailure=true`) still reports the warning, and whether the issue can close before the models are on by default is for the maintainers to decide.

Assisted-by: Claude Code (claude-opus-5-5)
@coderabbitai

coderabbitai Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
📥 Commits

Reviewing files that changed from the base of the PR and between 3035507 and ccb01f8.

📒 Files selected for processing: 1
  • nullaway/src/test/java/com/uber/nullaway/jspecify/GenericMethodTests.java

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 5 remain after this review.

Walkthrough

The previously ignored issue 1493 test is replaced by two enabled tests for Objects.requireNonNullElse. The tests use the same configuration except for the JSpecify JDK models setting. The test with models enabled expects no diagnostic. The test with models disabled expects a generic inference-failure diagnostic.

Suggested reviewers: msridhar

Priority: ⬇️ Low

Change: Other

Merge Risk: ⚪ Minimal · up to ccb01

The test change is ready to merge after normal checks; no actionable merge-blocking issue was identified.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly identifies the main change: testing requireNonNullElse inference with and without JSpecify JDK models.
Description check Passed The description accurately explains the two tests, their configuration, expected diagnostics, and relationship to issue #1493.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches: 💡 1
🧪 Generate unit tests (beta)
  • Create a new PR
🛠️ Fix failing CI checks: 💡
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Oct 22, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.13%. Comparing base (5023d67) to head (ccb01f8).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #2033      +/-   ##
============================================
+ Coverage     88.92%   89.13%   +0.21%     
  Complexity       38       38              
============================================
  Files           118      119       +1     
  Lines         12601    12707     +106     
  Branches       2550     2580      +30     
============================================
+ Hits          11206    11327     +121     
+ Misses          629      623       -6     
+ Partials        766      757       -9     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@msridhar
msridhar added this pull request to the merge queue Oct 23, 2026
Merged via the queue into apache:master with commit fc8c990 Oct 23, 2026
19 of 20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants