Skip to content

Fixes for processing return array types and multi-dimensional array types in AstubxGenerator - #1689

Merged
msridhar merged 3 commits into
masterfrom
nullable-array-contents-from-libmodel
Aug 9, 2026
Merged

Fixes for processing return array types and multi-dimensional array types in AstubxGenerator#1689
msridhar merged 3 commits into
masterfrom
nullable-array-contents-from-libmodel

Conversation

@msridhar

@msridhar msridhar commented Aug 8, 2026

Copy link
Copy Markdown
Collaborator

Apply special logic for parameter types to return types also, and add fixes for multi-dimensional arrays. Most of the changes are in tests.

Summary by CodeRabbit

  • Bug Fixes

    • Improved nullness handling for generic type signatures, including qualified and simple nullable annotations.
    • Correctly distinguishes nullable array references from nullable array elements, including cases where both are nullable.
    • Improved handling of nullable annotations on varargs signatures.
  • Tests

    • Added coverage for serialized annotations and integration diagnostics involving nullable arrays and elements.
    • Added scenarios covering nullable arrays, nullable elements, and combined nullability.

@msridhar

msridhar commented Aug 8, 2026

Copy link
Copy Markdown
Collaborator Author

This change is part of the following stack:

Change managed by git-spice.

@msridhar
msridhar requested a review from yuxincs August 9, 2026 00:01
@coderabbitai

coderabbitai Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

AstubxGenerator now handles nullable annotations across return and argument type signatures, including arrays, varargs, and qualified or simple @Nullable forms. Tests cover nullable array references, elements, multidimensional arrays, and combined annotations. Integration tests verify the corresponding NullAway diagnostics. An ignored JDK model test covers nullable arrays returned by MessageFormat.

Possibly related issues

  • Issue 950: Extends JSpecify JDK model generation for nullable array return-type annotations.

Possibly related PRs

  • uber/NullAway#1243: Directly relates to AstubxGenerator return-signature parsing and generator tests.
  • uber/NullAway#1497: Relates to top-level nullness handling for parameter and varargs signatures.
  • uber/NullAway#1641: Relates to JSpecify JDK annotation handling and nullable array tests.

Suggested reviewers: lazaroclapp, yuxincs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main changes to return array and multidimensional array processing in AstubxGenerator.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch nullable-array-contents-from-libmodel

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.

@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: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@jdk-annotations/astubx-generator/src/main/java/com/uber/nullaway/jdkannotations/AstubxGenerator.java`:
- Around line 392-397: Update the array detection logic in AstubxGenerator to
inspect only the annotation immediately before the final [] dimension, so
inner-dimension annotations in multidimensional types are not classified as
top-level nullness. Adjust ARRAY_NULLNESS_ANNOTATION_PATTERN or its matching
logic accordingly, and add an AstubxTest regression covering String `@Nullable`
[][].

In
`@jdk-annotations/jdk-integration-test/src/test/java/com/uber/nullaway/jdkannotations/JDKIntegrationTest.java`:
- Around line 336-349: Update JDKIntegrationTest around the nullable array and
nullable element assignment checks to avoid annotating local variables with
`@Nullable`. Pass each ReturnAnnotation result directly to matching annotated
parameters, using ParameterAnnotation.takesNullableArray() for nullable array
values and takesNullableElements() for nullable-element values, while preserving
the existing incompatible-type diagnostics.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 9cac7963-c109-419c-ab4c-daf829bb71bd

📥 Commits

Reviewing files that changed from the base of the PR and between c338eba and 3964458.

📒 Files selected for processing (6)
  • jdk-annotations/astubx-generator/src/main/java/com/uber/nullaway/jdkannotations/AstubxGenerator.java
  • jdk-annotations/astubx-generator/src/test/java/com/uber/nullaway/jdkannotations/AstubxTest.java
  • jdk-annotations/jdk-integration-test/src/test/java/com/uber/nullaway/jdkannotations/JDKIntegrationTest.java
  • jdk-annotations/test-annotated/src/main/java/com/uber/nullaway/jdkannotations/ReturnAnnotation.java
  • jdk-annotations/test-unannotated/src/main/java/com/uber/nullaway/jdkannotations/ReturnAnnotation.java
  • nullaway/src/test/java/com/uber/nullaway/JSpecifyJDKModelsTest.java

@codecov

codecov Bot commented Aug 9, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.30769% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 87.87%. Comparing base (a5903b1) to head (3772af0).

Files with missing lines Patch % Lines
.../uber/nullaway/jdkannotations/AstubxGenerator.java 92.30% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #1689      +/-   ##
============================================
- Coverage     87.87%   87.87%   -0.01%     
  Complexity     3167     3167              
============================================
  Files           109      109              
  Lines         10742    10739       -3     
  Branches       2172     2171       -1     
============================================
- Hits           9440     9437       -3     
  Misses          617      617              
  Partials        685      685              

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

Base automatically changed from biconsumer-model to master August 9, 2026 00:15
@msridhar
msridhar force-pushed the nullable-array-contents-from-libmodel branch from 947908f to 00653d3 Compare August 9, 2026 01:42
@msridhar msridhar changed the title Properly handle nullable annotations on return array types in JSpecify JDK Fixes for processing return array types and multi-dimensional array types in AstubxGenerator Aug 9, 2026

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
jdk-annotations/astubx-generator/src/main/java/com/uber/nullaway/jdkannotations/AstubxGenerator.java (1)

409-418: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Add Javadoc for both private helpers.

stripAnnotationsFromTypeSignature and buildTypeSignatureAnnotationPattern define the signature-key transformation. Document their behavior and the varargs case.

As per coding guidelines, “Add Javadoc for every non-trivial method, including private methods.”

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@jdk-annotations/astubx-generator/src/main/java/com/uber/nullaway/jdkannotations/AstubxGenerator.java`
around lines 409 - 418, Add Javadoc to both private helpers,
stripAnnotationsFromTypeSignature and buildTypeSignatureAnnotationPattern,
describing their signature-transformation behavior. Document that annotation
removal handles annotations followed by whitespace and annotations applied
directly to top-level varargs arrays before the ellipsis.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In
`@jdk-annotations/astubx-generator/src/main/java/com/uber/nullaway/jdkannotations/AstubxGenerator.java`:
- Around line 409-418: Add Javadoc to both private helpers,
stripAnnotationsFromTypeSignature and buildTypeSignatureAnnotationPattern,
describing their signature-transformation behavior. Document that annotation
removal handles annotations followed by whitespace and annotations applied
directly to top-level varargs arrays before the ellipsis.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 30c2dcc3-2ef8-4e8f-a19c-da489bd11e9f

📥 Commits

Reviewing files that changed from the base of the PR and between 947908f and 3772af0.

📒 Files selected for processing (5)
  • jdk-annotations/astubx-generator/src/main/java/com/uber/nullaway/jdkannotations/AstubxGenerator.java
  • jdk-annotations/astubx-generator/src/test/java/com/uber/nullaway/jdkannotations/AstubxTest.java
  • jdk-annotations/jdk-integration-test/src/test/java/com/uber/nullaway/jdkannotations/JDKIntegrationTest.java
  • jdk-annotations/test-annotated/src/main/java/com/uber/nullaway/jdkannotations/ReturnAnnotation.java
  • jdk-annotations/test-unannotated/src/main/java/com/uber/nullaway/jdkannotations/ReturnAnnotation.java

@msridhar
msridhar enabled auto-merge (squash) August 9, 2026 03:19
@msridhar
msridhar merged commit 7489d69 into master Aug 9, 2026
14 checks passed
@msridhar
msridhar deleted the nullable-array-contents-from-libmodel branch August 9, 2026 03:20
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