Skip to content

Run NullAway on jdk-javac-plugin code - #1408

Merged
msridhar merged 1 commit into
masterfrom
run-nullaway-on-javac-plugin
Dec 25, 2025
Merged

msridhar merged 1 commit into
masterfrom
run-nullaway-on-javac-plugin

Conversation

@msridhar

@msridhar msridhar commented Dec 25, 2025 •

Copy link
Copy Markdown
Collaborator

No behavioral changes.

Summary by CodeRabbit

  • Chores
    • Enhanced build-time null-safety verification with automated error checking to catch potential issues earlier in the development process.
    • Improved code robustness through strengthened null-pointer handling and annotations to ensure greater reliability.

✏️ Tip: You can customize this high-level summary in your review settings.

@codecov

codecov Bot commented Dec 25, 2025 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.35%. Comparing base (c86f08d) to head (2c81bc0).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##             master    #1408   +/-   ##
=========================================
  Coverage     88.35%   88.35%           
  Complexity     2662     2662           
=========================================
  Files            98       98           
  Lines          8895     8897    +2     
  Branches       1765     1765           
=========================================
+ Hits           7859     7861    +2     
  Misses          514      514           
  Partials        522      522           

☔ 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 commented Dec 25, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

The PR enables NullAway Error Prone checks in the jdk-javac-plugin build configuration with specific options (OnlyNullMarked, JSuppressMode, AcknowledgeRestrictiveAnnotations) set to ERROR severity, and adds the nullaway module as an annotation processor dependency. Additionally, NullnessAnnotationSerializer is annotated with @NullMarked, visitor methods in its internal TreePathScanner are updated to use @Nullable Void return types, and null-safety checks using Objects.requireNonNull are introduced to prevent potential null dereferences.

Possibly related PRs

Suggested reviewers

  • yuxincs
  • lazaroclapp

Pre-merge checks and finishing touches

❌ 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%. 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 'Run NullAway on jdk-javac-plugin code' accurately describes the main objective of the PR: enabling NullAway static analysis checks on the jdk-javac-plugin module.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch run-nullaway-on-javac-plugin

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c86f08d and 2c81bc0.

📒 Files selected for processing (2)
  • jdk-javac-plugin/build.gradle
  • jdk-javac-plugin/src/main/java/com/uber/nullaway/javacplugin/NullnessAnnotationSerializer.java
🧰 Additional context used
🧠 Learnings (8)
📓 Common learnings
Learnt from: msridhar
Repo: uber/NullAway PR: 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.
Learnt from: msridhar
Repo: uber/NullAway PR: 1248
File: nullaway/src/main/java/com/uber/nullaway/generics/GenericsChecks.java:847-857
Timestamp: 2025-08-28T04:54:20.953Z
Learning: In NullAway's GenericsChecks.java, NewClassTree support for explicit type argument substitution requires more extensive changes beyond just modifying the conditional in compareGenericTypeParameterNullabilityForCall. The maintainers prefer to handle NewClassTree support in a separate follow-up rather than expanding the scope of PRs focused on specific issues like super constructor calls.
Learnt from: CR
Repo: uber/NullAway PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-25T22:43:06.446Z
Learning: Run only the tests for the main NullAway module using `./gradlew :nullaway:test` unless specifically asked to run tests in a different module
Learnt from: msridhar
Repo: uber/NullAway PR: 1259
File: jdk-recent-unit-tests/src/test/java/com/uber/nullaway/jdk17/SwitchTests.java:318-321
Timestamp: 2025-08-29T18:41:43.584Z
Learning: Classes annotated with NullMarked are analyzed by NullAway even if they are not in packages specified by the AnnotatedPackages configuration. The NullMarked annotation guarantees NullAway analysis.
Learnt from: msridhar
Repo: uber/NullAway PR: 1316
File: jdk-javac-plugin/src/main/java/com/uber/nullaway/javacplugin/NullnessAnnotationSerializer.java:261-293
Timestamp: 2025-10-29T23:56:18.236Z
Learning: In NullAway's jdk-javac-plugin NullnessAnnotationSerializer, type variable bounds with annotations (e.g., `T extends Nullable Object`) are checked at their declaration sites by the typeParamHasAnnotation method for both class-level and method-level type parameters. The hasJSpecifyAnnotationDeep method is designed to check type uses (return types, parameters, etc.) and does not need a TYPEVAR case because type variable declaration bounds are already handled separately.
Learnt from: haewiful
Repo: uber/NullAway PR: 1243
File: jdk-annotations/astubx-generator-cli/src/main/java/com/uber/nullaway/jdkannotations/AstubxGeneratorCLI.java:97-106
Timestamp: 2025-09-24T23:14:37.777Z
Learning: In the jdk-javac-plugin NullnessAnnotationSerializer, the plugin only creates one JSON file per compilation, so processing only the first JSON file is intentional behavior rather than a bug.
📚 Learning: 2025-08-14T18:50:06.159Z
Learnt from: msridhar
Repo: uber/NullAway PR: 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:

  • jdk-javac-plugin/build.gradle
  • jdk-javac-plugin/src/main/java/com/uber/nullaway/javacplugin/NullnessAnnotationSerializer.java
📚 Learning: 2025-09-24T23:14:37.777Z
Learnt from: haewiful
Repo: uber/NullAway PR: 1243
File: jdk-annotations/astubx-generator-cli/src/main/java/com/uber/nullaway/jdkannotations/AstubxGeneratorCLI.java:97-106
Timestamp: 2025-09-24T23:14:37.777Z
Learning: In the jdk-javac-plugin NullnessAnnotationSerializer, the plugin only creates one JSON file per compilation, so processing only the first JSON file is intentional behavior rather than a bug.

Applied to files:

  • jdk-javac-plugin/build.gradle
  • jdk-javac-plugin/src/main/java/com/uber/nullaway/javacplugin/NullnessAnnotationSerializer.java
📚 Learning: 2025-11-25T22:43:06.446Z
Learnt from: CR
Repo: uber/NullAway PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-25T22:43:06.446Z
Learning: Run only the tests for the main NullAway module using `./gradlew :nullaway:test` unless specifically asked to run tests in a different module

Applied to files:

  • jdk-javac-plugin/build.gradle
📚 Learning: 2025-11-25T22:43:06.446Z
Learnt from: CR
Repo: uber/NullAway PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-25T22:43:06.446Z
Learning: Use the `--tests` flag with gradle to run specific test classes or methods, e.g., `./gradlew :nullaway:test --tests "com.uber.nullaway.NullAwayTest"`

Applied to files:

  • jdk-javac-plugin/build.gradle
📚 Learning: 2025-08-29T18:41:43.584Z
Learnt from: msridhar
Repo: uber/NullAway PR: 1259
File: jdk-recent-unit-tests/src/test/java/com/uber/nullaway/jdk17/SwitchTests.java:318-321
Timestamp: 2025-08-29T18:41:43.584Z
Learning: Classes annotated with NullMarked are analyzed by NullAway even if they are not in packages specified by the AnnotatedPackages configuration. The NullMarked annotation guarantees NullAway analysis.

Applied to files:

  • jdk-javac-plugin/src/main/java/com/uber/nullaway/javacplugin/NullnessAnnotationSerializer.java
📚 Learning: 2025-08-28T04:54:20.953Z
Learnt from: msridhar
Repo: uber/NullAway PR: 1248
File: nullaway/src/main/java/com/uber/nullaway/generics/GenericsChecks.java:847-857
Timestamp: 2025-08-28T04:54:20.953Z
Learning: In NullAway's GenericsChecks.java, NewClassTree support for explicit type argument substitution requires more extensive changes beyond just modifying the conditional in compareGenericTypeParameterNullabilityForCall. The maintainers prefer to handle NewClassTree support in a separate follow-up rather than expanding the scope of PRs focused on specific issues like super constructor calls.

Applied to files:

  • jdk-javac-plugin/src/main/java/com/uber/nullaway/javacplugin/NullnessAnnotationSerializer.java
📚 Learning: 2025-10-29T23:56:18.236Z
Learnt from: msridhar
Repo: uber/NullAway PR: 1316
File: jdk-javac-plugin/src/main/java/com/uber/nullaway/javacplugin/NullnessAnnotationSerializer.java:261-293
Timestamp: 2025-10-29T23:56:18.236Z
Learning: In NullAway's jdk-javac-plugin NullnessAnnotationSerializer, type variable bounds with annotations (e.g., `T extends Nullable Object`) are checked at their declaration sites by the typeParamHasAnnotation method for both class-level and method-level type parameters. The hasJSpecifyAnnotationDeep method is designed to check type uses (return types, parameters, etc.) and does not need a TYPEVAR case because type variable declaration bounds are already handled separately.

Applied to files:

  • jdk-javac-plugin/src/main/java/com/uber/nullaway/javacplugin/NullnessAnnotationSerializer.java
🧬 Code graph analysis (1)
jdk-javac-plugin/src/main/java/com/uber/nullaway/javacplugin/NullnessAnnotationSerializer.java (2)
jdk-annotations/test-annotated/src/main/java/com/uber/nullaway/jdkannotations/ParameterAnnotation.java (1)
  • NullMarked (7-67)
jdk-annotations/test-annotated/src/main/java/com/uber/nullaway/jdkannotations/ReturnAnnotation.java (1)
  • NullMarked (8-84)
⏰ 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 macos-latest
  • GitHub Check: Build and test on ubuntu-latest
  • GitHub Check: Build caffeine with snapshot
🔇 Additional comments (6)
jdk-javac-plugin/build.gradle (3)

1-2: LGTM! Import is necessary for Error Prone configuration.

The import of CheckSeverity is correctly added to support setting NullAway and RequireExplicitNullMarking checks to ERROR severity in the configuration below.


56-57: LGTM! Annotation processor dependency is correctly configured.

The annotationProcessor dependency on the nullaway project is necessary to enable NullAway checks during compilation of this module.


38-46: No issues found. The Error Prone configuration correctly uses all three NullAway options with the correct spelling: OnlyNullMarked, JSpecifyMode, and AcknowledgeRestrictiveAnnotations. All option names are officially supported and widely used throughout the codebase.

jdk-javac-plugin/src/main/java/com/uber/nullaway/javacplugin/NullnessAnnotationSerializer.java (3)

27-27: LGTM! Enabling null-safety checking with @NullMarked.

The addition of @NullMarked annotation appropriately enables NullAway checking for this class, aligning with the PR objective. The required imports for Objects and NullMarked are correctly added.

Also applies to: 34-34, 41-41


86-86: LGTM! Proper null-safety annotations for the scanner.

The changes correctly handle nullability:

  • Scanner type parameters changed to @Nullable Void because the visitor methods return null
  • classStack appropriately made final since it's never reassigned
  • currentClass correctly annotated @Nullable as it's initialized to null and can be cleared
  • Method signatures properly updated to match the scanner's type parameters

Also applies to: 88-88, 90-90, 93-93, 150-150


101-103: The Objects.requireNonNull() assertion is safe and adequately tested.

Test coverage confirms classSym.packge().getEnclosingElement() never returns null for either named or unnamed modules (nullMarkedClassNoModule() and nullMarkedClassWithModule() both pass). The change was made to satisfy NullAway's null-safety requirements, and the code correctly handles unnamed modules by checking if the result is empty.


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 requested review from Copilot and yuxincs and removed request for Copilot December 25, 2025 22:53
@msridhar
msridhar enabled auto-merge (squash) December 25, 2025 22:53
@msridhar
msridhar merged commit 17d3462 into master Dec 25, 2025
10 of 11 checks passed
@msridhar
msridhar deleted the run-nullaway-on-javac-plugin branch December 25, 2025 22:54
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