Update all Java version references to require Java 21#32
Update all Java version references to require Java 21#32devin-ai-integration[bot] wants to merge 1 commit into
Conversation
Co-Authored-By: Dillon Vargo <dillonvargo@gmail.com>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
| if (version.startsWith("1.")) { | ||
| majorVersion = Integer.parseInt(version.substring(2, 3)); | ||
| } else { | ||
| majorVersion = Integer.parseInt(version.split("\\.")[0]); |
There was a problem hiding this comment.
🟡 Version parsing fails for JDK pre-release strings like "21-ea", incorrectly rejecting valid Java 21+ runtimes
When java.version contains no dots but has a pre-release suffix (e.g., "21-ea" for early access builds, or "21-internal" for custom builds), version.split("\\.")[0] returns the full string "21-ea". Integer.parseInt("21-ea") then throws NumberFormatException, which is caught and sets majorVersion = 0. Since 0 < 21, the method throws an APIException even though the JVM is actually Java 21. Per JEP 223, valid java.version formats include $MAJOR-$PRE (e.g., "21-ea"), so this is a realistic input. The fix should strip any suffix after - or + before parsing, e.g., version.split("\\.")[0].split("[-+]")[0].
| majorVersion = Integer.parseInt(version.split("\\.")[0]); | |
| majorVersion = Integer.parseInt(version.split("[-+.]")[0]); |
Was this helpful? React with 👍 or 👎 to provide feedback.
Description of what I changed
Updated all outdated Java version references across the repository to consistently require Java 21:
test-module/pom.xml: Changed<javaCompilerVersion>from1.8to21.OpenmrsUtil.java: RewrotevalidateJavaVersion()to properly parse modern Java version strings (e.g.21.0.1) and enforce Java 21 as the minimum. The previous regex-based check (1\\.[0-7]\\.(.*)) only caught pre-Java-8 versions using the legacy1.xnaming scheme and could not enforce any minimum above Java 8.README.md: Updated the documented minimum Java version from 8 to 21.Issue I worked on
see https://issues.openmrs.org/browse/TRUNK-
Things for reviewers to verify
validateJavaVersion()(if any) have been updated or still pass under the new logic.nullreturn fromSystem.getProperty("java.version")(same as the old code) — acceptable or worth a guard?Checklist: I completed these to help reviewers :)
mvn clean packageright before creating this pull request and added all formatting changes to my commit.Link to Devin session: https://app.devin.ai/sessions/299fa49e325440a29947a8971070be82