Skip to content

Update all Java version references to require Java 21#32

Open
devin-ai-integration[bot] wants to merge 1 commit into
masterfrom
devin/1775568064-java-21-version-update
Open

Update all Java version references to require Java 21#32
devin-ai-integration[bot] wants to merge 1 commit into
masterfrom
devin/1775568064-java-21-version-update

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Apr 7, 2026

Copy link
Copy Markdown

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> from 1.8 to 21.
  • OpenmrsUtil.java: Rewrote validateJavaVersion() 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 legacy 1.x naming 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

  • Confirm that existing tests for validateJavaVersion() (if any) have been updated or still pass under the new logic.
  • The new method does not handle a null return from System.getProperty("java.version") (same as the old code) — acceptable or worth a guard?

Checklist: I completed these to help reviewers :)

  • My IDE is configured to follow the code style of this project.
  • I have added tests to cover my changes. (If you refactored existing code that was well tested you do not have to add tests)
  • I ran mvn clean package right before creating this pull request and added all formatting changes to my commit.
  • All new and existing tests passed.
  • My pull request is based on the latest changes of the master branch.

Link to Devin session: https://app.devin.ai/sessions/299fa49e325440a29947a8971070be82


Open with Devin

Co-Authored-By: Dillon Vargo <dillonvargo@gmail.com>
@devin-ai-integration

Copy link
Copy Markdown
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 potential issue.

View 4 additional findings in Devin Review.

Open in Devin Review

if (version.startsWith("1.")) {
majorVersion = Integer.parseInt(version.substring(2, 3));
} else {
majorVersion = Integer.parseInt(version.split("\\.")[0]);

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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].

Suggested change
majorVersion = Integer.parseInt(version.split("\\.")[0]);
majorVersion = Integer.parseInt(version.split("[-+.]")[0]);
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

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.

0 participants