Skip to content

require java 21, since jruby 10 requires it#19010

Merged
yaauie merged 1 commit intoelastic:mainfrom
yaauie:require-java-21
Apr 16, 2026
Merged

require java 21, since jruby 10 requires it#19010
yaauie merged 1 commit intoelastic:mainfrom
yaauie:require-java-21

Conversation

@yaauie
Copy link
Copy Markdown
Member

@yaauie yaauie commented Apr 16, 2026

Release notes

Sets the minimum version of Java to 21.

What does this PR do?

Updates the check in the JVMOptionsParser to provide helpful output when logstash is invoked with a JVM that does not meet JRuby 10's minimum requirement.

Why is it important/What is the impact to the user?

Without this, invoking Logstash on JVM 17 produces an obscure and unhelpful error message:

╭─{ rye@perhaps:~/src/elastic/logstash@main }
╰─● (jenv shell 17; bin/logstash -e '')
Using system java: /Users/rye/.jenv/shims/java
Error: Unable to initialize main class org.logstash.Logstash
Caused by: java.lang.UnsupportedClassVersionError: org/jruby/exceptions/RaiseException has been compiled by a more recent version of the Java Runtime (class file version 65.0), this version of the Java Runtime only recognizes class file versions up to 61.0
[error: 1] 

With it, the message is helpful and clear:

╭─{ rye@perhaps:~/src/elastic/logstash@main (require-java-21 ✘) }
╰─● (jenv shell 17; bin/logstash -e '')
Using system java: /Users/rye/.jenv/shims/java
The minimum required Java version is 21; your Java version from [/opt/homebrew/Cellar/openjdk@17/17.0.15/libexec/openjdk.jdk/Contents/Home] is [17] and does not meet this requirement
[error: 1]

Checklist

  • My code follows the style guidelines of this project
  • [ ] I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • [ ] I have made corresponding change to the default configuration files (and/or docker env variables)
  • [ ] I have added tests that prove my fix is effective or that my feature works

How to test this PR locally

  • Build Logstash normally with Java 21
  • Launch Logstash with Java 17
    • jenv: (jenv shell 17; bin/logstash -e "")
    • LS_JAVA_HOME LS_JAVA_HOME=/path/to/java17 bin/logstash -e ""

Related issues

Use cases

@github-actions
Copy link
Copy Markdown
Contributor

🤖 GitHub comments

Just comment with:

  • run docs-build : Re-trigger the docs validation. (use unformatted text in the comment!)
  • run exhaustive tests : Run the exhaustive tests Buildkite pipeline.

@yaauie yaauie mentioned this pull request Apr 16, 2026
@donoghuc donoghuc self-requested a review April 16, 2026 18:01
@elasticmachine
Copy link
Copy Markdown

💚 Build Succeeded

Copy link
Copy Markdown
Member

@donoghuc donoghuc left a comment

Choose a reason for hiding this comment

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

Looks good, just one suggestion/question about deprecation logging.


if JavaVersion::CURRENT < JavaVersion::JAVA_17
deprecation_logger.deprecated I18n.t("logstash.runner.java.version_17_minimum",
if JavaVersion::CURRENT < JavaVersion::JAVA_21
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think this is now no longer reachable? I think bailOnOldJava would stop execution before this can execute. We would introduce this again if there were multiple java versions supported (and one was to be deprecated soon).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

You're right that it is likely unreachable. Let's file a separate ticket to chase it. For now I'm just updating the bits that are there just in case there is a path to it that I can't think of.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@yaauie yaauie requested a review from donoghuc April 16, 2026 19:13
Copy link
Copy Markdown
Member

@donoghuc donoghuc left a comment

Choose a reason for hiding this comment

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

Good catch!

@yaauie yaauie merged commit 4a51726 into elastic:main Apr 16, 2026
14 checks passed
@yaauie
Copy link
Copy Markdown
Member Author

yaauie commented Apr 16, 2026

@Mergifyio backport 9.4

@yaauie yaauie deleted the require-java-21 branch April 16, 2026 20:08
@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented Apr 16, 2026

backport 9.4

✅ Backports have been created

Details

mergify Bot pushed a commit that referenced this pull request Apr 16, 2026
yaauie added a commit that referenced this pull request Apr 16, 2026
(cherry picked from commit 4a51726)

Co-authored-by: Rye Biesemeyer <yaauie@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants