[PR #12127] fix(lsp): handle Java versions without minor/patch numbers #14077

Open
opened 2026-02-16 18:18:53 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/12127

State: open
Merged: No


What does this PR do?

Fixes Java version detection for JDTLS installation when java -version outputs only the major version.

Problem: The regex /"(\d+)\.\d+\.\d+"/ expects format like "21.0.0", but some distributions (e.g., Temurin-21+35) output just "21":

openjdk version "21" 2023-09-19 LTS

Fix: Changed regex to /"(\d+)(?:\.\d+)*"/ which matches both formats.

Fixes #12120

How did you verify your code works?

Tested the regex against multiple Java version string formats:

// All return the correct major version:
"21"     -> 21   (was failing before)
"21.0.0" -> 21  
"21.0.5" -> 21  
"17.0.2" -> 17  
**Original Pull Request:** https://github.com/anomalyco/opencode/pull/12127 **State:** open **Merged:** No --- ### What does this PR do? Fixes Java version detection for JDTLS installation when `java -version` outputs only the major version. **Problem:** The regex `/"(\d+)\.\d+\.\d+"/` expects format like `"21.0.0"`, but some distributions (e.g., Temurin-21+35) output just `"21"`: ``` openjdk version "21" 2023-09-19 LTS ``` **Fix:** Changed regex to `/"(\d+)(?:\.\d+)*"/` which matches both formats. Fixes #12120 ### How did you verify your code works? Tested the regex against multiple Java version string formats: ```javascript // All return the correct major version: "21" -> 21 ✓ (was failing before) "21.0.0" -> 21 ✓ "21.0.5" -> 21 ✓ "17.0.2" -> 17 ✓ ```
yindo added the pull-request label 2026-02-16 18:18:53 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#14077