Repository navigation
Fix Java version detection - #45
Conversation
|
Warning Review limit reachedYou'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. View limit details
No actionable comments were generated in the recent review.
|
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>
The regex that extracts the Java version from
java -versionkept two components of the version number, so JDK11.0.11yielded11.0, which matches none of thejava_versionchecks; such JDKs fell through to the newest google-java-format.Now a new function,
parse_java_version, returns the major version as an integer (8for1.8.0_292,11for11.0.11). It reads only the version line, so preceding lines such asPicked 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:
Likewise, the
--add-exportsflags are omitted for every JDK before 9, not just JDK 8.The documentation of
parse_java_versionshowsjava -versionoutput; the old comment showedjava --versionoutput.Add unit tests for
parse_java_version, run bymake testin CircleCI and GitHub Actions.