Skip to content

CAMEL-23112: Lower minimum JDK requirement from 21 to 17#21991

Open
gnodet wants to merge 8 commits intomainfrom
camel-jdk17-support
Open

CAMEL-23112: Lower minimum JDK requirement from 21 to 17#21991
gnodet wants to merge 8 commits intomainfrom
camel-jdk17-support

Conversation

@gnodet
Copy link
Contributor

@gnodet gnodet commented Mar 13, 2026

Summary

  • Lower the minimum JDK version from 21 to 17 using Multi-Release JAR (MRJAR) infrastructure
  • JDK 21+ users retain all benefits (virtual threads, ScopedValue) — they are loaded automatically via MRJAR at runtime
  • JDK 17 users get platform threads and ThreadLocal as graceful fallbacks

Changes

  • Root pom.xml: jdk.version 21 → 17
  • CamelThreadFactory: JDK 17 base version uses new Thread(). JDK 21 version (with Thread.ofVirtual()/Thread.ofPlatform()) moved to src/main/java21/ MRJAR directory in camel-util
  • JsonObject: Replaced List.getLast() (JDK 21 SequencedCollection) with list.get(list.size() - 1), and String.splitWithDelimiters() (JDK 21) with a Pattern/Matcher equivalent
  • ManagedVirtualThreadExecutorTest: Added @EnabledForJreRange(min = JAVA_21) since it uses Executors.newVirtualThreadPerTaskExecutor()

Trade-offs

Benefits Costs
Broader adoption (JDK 17 LTS widely deployed) Virtual threads unavailable on JDK 17
Lower barrier for enterprise users ScopedValue falls back to ThreadLocal
Aligns with JDK 17 LTS support (until Sept 2029) CI matrix grows (17 + 21 + 25)

Test plan

  • Full build and test on JDK 17
  • Full build and test on JDK 21 (verify MRJAR virtual threads still work)
  • Full build and test on JDK 25 (verify ScopedValue via MRJAR)
  • Verify camel-util JAR contains META-INF/versions/21/org/apache/camel/util/concurrent/CamelThreadFactory.class

JIRA: https://issues.apache.org/jira/browse/CAMEL-23112

- Change jdk.version from 21 to 17 in root pom.xml
- Create JDK 17 fallback for CamelThreadFactory using new Thread()
- Move JDK 21 CamelThreadFactory (virtual threads) to MRJAR java21/ directory
- Replace List.getLast() (JDK 21) with index-based access in JsonObject
- Replace String.splitWithDelimiters() (JDK 21) with Pattern/Matcher in JsonObject
- Add @EnabledForJreRange(min=JAVA_21) to ManagedVirtualThreadExecutorTest

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions
Copy link
Contributor

🌟 Thank you for your contribution to the Apache Camel project! 🌟
🤖 CI automation will test this PR automatically.

🐫 Apache Camel Committers, please review the following items:

  • First-time contributors require MANUAL approval for the GitHub Actions to run
  • You can use the command /component-test (camel-)component-name1 (camel-)component-name2.. to request a test from the test bot although they are normally detected and executed by CI.
  • You can label PRs using build-all, build-dependents, skip-tests and test-dependents to fine-tune the checks executed by this PR.
  • Build and test logs are available in the summary page. Only Apache Camel committers have access to the summary.

⚠️ Be careful when sharing logs. Review their contents before sharing them publicly.

gnodet and others added 7 commits March 13, 2026 15:08
SSLParameters.getNamedGroups/setNamedGroups (JDK 20) and
getSignatureSchemes/setSignatureSchemes (JDK 19) are called
via reflection so the code compiles and runs on JDK 17.
On JDK 17, these SSL configuration options are silently skipped.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Replace Executors.newThreadPerTaskExecutor() (JDK 21) with
  reflection in DefaultThreadPoolFactory VIRTUAL enum
- Replace Thread.threadId() (JDK 19) with Thread.getId() in
  ExpressionBuilder.threadIdExpression()

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The applyPqcNamedGroupDefaults method added in main uses
SSLParameters.getNamedGroups() (JDK 20+) directly. Use the
reflection-based getNamedGroupsFromParams() helper instead.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Use reflection-based helpers for SSLParameters.getNamedGroups() and
getSignatureSchemes() (JDK 20/19 APIs) and add @EnabledForJreRange
annotations to skip these tests on JDK < 21 at runtime.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Use reflection to call Executors.newVirtualThreadPerTaskExecutor()
which is a JDK 21 API not available with --release 17 compilation.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace List.addFirst() (JDK 21 SequencedCollection) with
List.add(0, ...) in SpringAiImageOllamaIT.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@gnodet gnodet changed the title Lower minimum JDK requirement from 21 to 17 CAMEL-23112: Lower minimum JDK requirement from 21 to 17 Mar 13, 2026
@gnodet gnodet marked this pull request as ready for review March 14, 2026 21:36
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