Skip to content

Fix Java version detection - #45

Merged
mernst merged 4 commits into
masterfrom
java-version
Oct 27, 2026
Merged

mernst merged 4 commits into
masterfrom
java-version

Conversation

@mernst

@mernst mernst commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

The regex that extracts the Java version from java -version kept two components of the version number, so JDK 11.0.11 yielded 11.0, which matches none of the java_version checks; such JDKs fell through to the newest google-java-format.

Now a new function, parse_java_version, returns the major version as an integer (8 for 1.8.0_292, 11 for 11.0.11). It reads only the version line, so preceding lines such as Picked up JAVA_TOOL_OPTIONS: ... cannot confuse it.

The script chooses the default google-java-format version by range rather than by exact match, so every JDK gets a compatible version. This changes the default for JDKs other than 8, 11, 17, and 21, all of which used to get 1.36.1:

  • JDK 9-10 get 1.7.
  • JDK 12-16 get 1.24.0.
  • JDK 18-20 get 1.28.0.

Likewise, the --add-exports flags are omitted for every JDK before 9, not just JDK 8.

The documentation of parse_java_version shows java -version output; the old comment showed java --version output.

Add unit tests for parse_java_version, run by make test in CircleCI and GitHub Actions.

@coderabbitai

coderabbitai Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 18 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
Commits

Reviewing files that changed from the base of the PR and between 3b38cd4 and b347906.

Files selected for processing: 3
  • .github/workflows/prek.yaml
  • run-google-java-format.py
  • tests/test_parse_java_version.py

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 f642a96 and 3b38cd4.

Files selected for processing: 4
  • .circleci/config.yml
  • Makefile
  • run-google-java-format.py
  • tests/test_parse_java_version.py

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

Walkthrough

The script now parses legacy and modern Java version output into an integer major version. It uses version ranges to select Google Java Format defaults and applies the empty jdk_opens branch to all versions below 9. New unittest coverage checks parsing behavior. A Makefile target runs the tests, and the CI prek job invokes that target.

Priority: Normal

Change: Bug fix

Merge Risk: Minimal · previous review 3b38c

No merge-blocking issue is established from the supplied evidence; complete the normal checks before merging.

Pre-merge checks: Passed 3
Check name Status Explanation
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Documentation-only edits and deletions within survi…
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.
Full details: Docstring Coverage

Explanation

Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 4 functions across 2 files. (2 skipped: 2 unsupported.)

Finishing Touches: 💡 1
🛠️ Fix failing CI checks: 💡
  • Commit to this branch
  • Create a new PR
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • 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.

mernst and others added 3 commits October 27, 2026 14:01
Anchor the regex to the version line, so that preceding lines such as
"Picked up JAVA_TOOL_OPTIONS: ..." do not confuse it.  Add unit tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mernst
mernst merged commit ff2255a into master Oct 27, 2026
5 checks passed
@mernst
mernst deleted the java-version branch October 27, 2026 21:53
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.

1 participant