Skip to content

Add a self-contained test case for #1157 - #1289

Merged
msridhar merged 2 commits into
masterfrom
issue-1157-test
Sep 16, 2025
Merged

msridhar merged 2 commits into
masterfrom
issue-1157-test

Conversation

@msridhar

@msridhar msridhar commented Sep 16, 2025 •

Copy link
Copy Markdown
Collaborator

Inference works now for code like that of #1157 but the original test case doesn't work since we still lack JSpecify JDK models (#950). This PR adds a self-contained test case (not using the standard library) to show that inference now works correctly for this case.

Summary by CodeRabbit

  • Tests
    • Added a self-contained test that validates nullness inference and warnings for generic atomic field updaters under JSpecify nullness annotations. This expands coverage of complex generic scenarios and ensures consistent behavior when mixing nullable and non-null type bounds. The added test strengthens reliability and helps prevent regressions related to nullness modeling with generic updaters.

@coderabbitai

coderabbitai Bot commented Sep 16, 2025 •

Copy link
Copy Markdown
Contributor

Walkthrough

A new public test method, atomicReferenceFieldUpdaterSelfContained(), was added to GenericMethodTests. The test injects a self-contained Java snippet using makeHelperWithInferenceFailureWarning() to validate NullAway with JSpecify models around AtomicReferenceFieldUpdater.newUpdater and related @Nullable/@nonnull generic type bounds.

Changes

Cohort / File(s) Summary
JSpecify NullAway tests
nullaway/src/test/java/com/uber/nullaway/jspecify/GenericMethodTests.java
Added test method atomicReferenceFieldUpdaterSelfContained() that builds a minimal Test.java with @NullMarked, uses org.jspecify.annotations.*, defines nested AtomicReferenceFieldUpdater and RESULT_UPDATER via newUpdater, and asserts inference/warning behavior using makeHelperWithInferenceFailureWarning().

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title "Add a self-contained test case for #1157" succinctly and accurately summarizes the primary change — adding a focused test that demonstrates the issue's behavior. It is concise, directly related to the changeset, and provides useful context by referencing the associated issue. This makes it clear and appropriate for a teammate scanning PR history.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch issue-1157-test

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 and usage tips.

@msridhar
msridhar enabled auto-merge (squash) September 16, 2025 17:25
@codecov

codecov Bot commented Sep 16, 2025 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.37%. Comparing base (3ba425f) to head (cc4917c).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #1289      +/-   ##
============================================
+ Coverage     88.34%   88.37%   +0.02%     
- Complexity     2465     2467       +2     
============================================
  Files            93       93              
  Lines          8188     8188              
  Branches       1614     1614              
============================================
+ Hits           7234     7236       +2     
+ Misses          480      479       -1     
+ Partials        474      473       -1     

☔ View full report in Codecov by Sentry.
📢 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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
nullaway/src/test/java/com/uber/nullaway/jspecify/GenericMethodTests.java (2)

1209-1215: Consider declaring the referenced field for clarity

Since the stub uses "result" as the field name, adding a matching field improves readability and mirrors real usage (no behavior change).

Apply this diff within the snippet:

-            "public class Test {",
+            "public class Test {",
+            "    @Nullable Object result;",
             "    static class AtomicReferenceFieldUpdater<T, V extends @Nullable Object> {",

1211-1212: Tiny style nit: add spaces after commas in type params

Keeps consistency with surrounding code.

-            "      public static <U,W extends @Nullable Object> AtomicReferenceFieldUpdater<U,W> ",
+            "      public static <U, W extends @Nullable Object> AtomicReferenceFieldUpdater<U, W> ",
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2e578d6 and 9791d83.

📒 Files selected for processing (1)
  • nullaway/src/test/java/com/uber/nullaway/jspecify/GenericMethodTests.java (1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: msridhar
PR: uber/NullAway#1245
File: guava-recent-unit-tests/src/test/java/com/uber/nullaway/guava/NullAwayGuavaParametricNullnessTests.java:101-102
Timestamp: 2025-08-14T18:50:06.159Z
Learning: In NullAway JSpecify tests, when JDK version requirements exist due to bytecode annotation reading capabilities, prefer failing tests over skipping them on unsupported versions to ensure CI catches regressions and enforces proper JDK version usage for developers.
📚 Learning: 2025-08-14T18:50:06.159Z
Learnt from: msridhar
PR: uber/NullAway#1245
File: guava-recent-unit-tests/src/test/java/com/uber/nullaway/guava/NullAwayGuavaParametricNullnessTests.java:101-102
Timestamp: 2025-08-14T18:50:06.159Z
Learning: In NullAway JSpecify tests, when JDK version requirements exist due to bytecode annotation reading capabilities, prefer failing tests over skipping them on unsupported versions to ensure CI catches regressions and enforces proper JDK version usage for developers.

Applied to files:

  • nullaway/src/test/java/com/uber/nullaway/jspecify/GenericMethodTests.java
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: Build and test on windows-latest
  • GitHub Check: Build and test on ubuntu-latest
  • GitHub Check: Build and test on macos-latest
  • GitHub Check: Build spring-framework with snapshot
🔇 Additional comments (1)
nullaway/src/test/java/com/uber/nullaway/jspecify/GenericMethodTests.java (1)

1197-1218: Self‑contained repro for #1157 looks good

Nice isolation of the inference behavior without relying on JDK models; aligns with our preference to fail (not skip) when environment is insufficient. No functional issues spotted.

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