Skip to content

Conversation

@msridhar
Copy link
Collaborator

@msridhar msridhar commented Aug 27, 2025

Some JSpecify tests now fail on earlier JDK 21 versions (see #1245). To avoid confusion, fail the whole build if one of these versions is being used.

Summary by CodeRabbit

  • Chores
    • Builds now require JDK 21.0.8+ when running on Java 21; earlier Java 21 updates will fail fast with a clear error before tasks run. This applies across all subprojects. No dependency or plugin changes. If you hit the error, upgrade your JDK to 21.0.8 or later; builds on other Java versions behave as before.

@msridhar msridhar requested a review from yuxincs August 27, 2025 16:52
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 27, 2025

Walkthrough

Adds a configuration-time guard in build.gradle that detects when running on JDK 21 and enforces a minimum runtime update (21.0.8); if the runtime is 21 with update < 8, the script throws a GradleException before evaluating subprojects. No other build logic changed.

Changes

Cohort / File(s) Summary
Build runtime guard
build.gradle
Adds a pre-subprojects configuration check: when JavaVersion.current() == VERSION_21, it reads Runtime.version() and if feature() == 21 and update() < 8 throws a GradleException requiring Java 21.0.8+.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant Dev as Developer
  participant Gradle as Gradle (configuration)
  participant JRE as Runtime.version()

  Dev->>Gradle: gradle build
  Gradle->>JRE: Runtime.version() → feature(), update()
  alt JDK 21 and update < 8
    Gradle-->>Dev: Throw GradleException ("Require Java 21.0.8 or newer")
  else Not JDK 21 or update ≥ 8
    Gradle-->>Dev: Continue evaluating subprojects
  end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch warn-on-early-JDK21

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

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

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@msridhar msridhar enabled auto-merge (squash) August 27, 2025 16:53
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

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 (1)
build.gradle (1)

48-50: Consider adding a reference to the related issue for context.

The error message is clear and actionable. Consider adding a reference to issue #1245 to provide additional context for developers encountering this error.

        throw new GradleException(
-                "Building NullAway on JDK 21 requires at least 21.0.8, but found ${runtimeVersion}.  Please upgrade to 21.0.8 or later, or to the most recent JDK release."
+                "Building NullAway on JDK 21 requires at least 21.0.8, but found ${runtimeVersion}.  Please upgrade to 21.0.8 or later, or to the most recent JDK release. See https://github.com/uber/NullAway/issues/1245 for more details."
        )
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between dedcd6c and 38cf41c.

📒 Files selected for processing (1)
  • build.gradle (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:

  • build.gradle
⏰ 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). (3)
  • GitHub Check: JDK 17 on windows-latest with Error Prone 2.41.0
  • GitHub Check: Build caffeine with snapshot
  • GitHub Check: Build spring-framework with snapshot
🔇 Additional comments (2)
build.gradle (2)

45-52: LGTM! Well-implemented version check with clear error messaging.

The implementation correctly validates the JDK 21 update version and provides a helpful error message. The check is placed appropriately before the subprojects block to prevent any configuration issues downstream.


45-52: Verify JDK 21 version-check logic handles all edge cases

I didn’t find any other JDK-version guards or CI overrides in the repo beyond the snippet in build.gradle (lines 45–52). To be confident this only rejects 21.0.{0–7} while accepting 21.0.8+ (and doesn’t misfire on “21-ea” or “21.1.0+9”), please:

• Add unit tests (or a small SmokeTest) exercising Runtime.version() against version strings like:
– “21”
– “21.0.7”
– “21.0.8”
– “21.0.8+9”
– “21.1.0”
– “21+9”
– “21-ea”
• Confirm that feature()==21 and update() returns the numeric patch level in all these cases.
• If Runtime.Version.parse behavior changes in future JDK-21.x/22, adjust the guard accordingly.

Locations to review:

  • build.gradle lines 45–52 (the existing feature/update check)

@codecov
Copy link

codecov bot commented Aug 27, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.17%. Comparing base (dedcd6c) to head (8d0f141).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##             master    #1261   +/-   ##
=========================================
  Coverage     88.17%   88.17%           
  Complexity     2427     2427           
=========================================
  Files            92       92           
  Lines          8010     8010           
  Branches       1595     1595           
=========================================
  Hits           7063     7063           
  Misses          492      492           
  Partials        455      455           

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

@msridhar msridhar merged commit d0e9bbb into master Aug 27, 2025
13 of 14 checks passed
@msridhar msridhar deleted the warn-on-early-JDK21 branch August 27, 2025 17:01
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

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 (1)
build.gradle (1)

45-52: Minor simplification and tweak to avoid redundancy and magic number.

The inner feature() == 21 check makes the outer JavaVersion.current() == VERSION_21 redundant. Also, name the minimum update to clarify intent and ease future bumps.

Apply:

-if (JavaVersion.current() == JavaVersion.VERSION_21) {
-    def runtimeVersion = Runtime.version()
-    if (runtimeVersion.feature() == 21 && runtimeVersion.update() < 8) {
-        throw new GradleException(
-        "Building NullAway on JDK 21 requires at least 21.0.8, but found ${runtimeVersion}.  Please upgrade to 21.0.8 or later, or to the most recent JDK release."
-        )
-    }
-}
+def runtimeVersion = Runtime.version()
+if (runtimeVersion.feature() == 21) {
+    def minUpdate = 8
+    if (runtimeVersion.update() < minUpdate) {
+        throw new GradleException(
+            "Building NullAway on JDK 21 requires at least 21.0.${minUpdate}, but found ${runtimeVersion}. Please upgrade to 21.0.${minUpdate} or later, or use the most recent JDK release."
+        )
+    }
+}
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 38cf41c and 8d0f141.

📒 Files selected for processing (1)
  • build.gradle (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:

  • build.gradle
⏰ 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). (3)
  • GitHub Check: JDK 17 on windows-latest with Error Prone 2.41.0
  • GitHub Check: Build spring-framework with snapshot
  • GitHub Check: Build caffeine with snapshot
🔇 Additional comments (1)
build.gradle (1)

45-52: Early, configuration-time JDK guard is appropriate and aligns with PR intent.

This will fail fast on unsupported 21.x runtimes and avoids confusing test failures. Placement before subprojects ensures a single, clear error.

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.

3 participants