Fix Java detection fallback when Ballerina dependencies directory is missing#1557
Closed
Copilot wants to merge 2 commits intorelease/bi-1.8.xfrom
Closed
Fix Java detection fallback when Ballerina dependencies directory is missing#1557Copilot wants to merge 2 commits intorelease/bi-1.8.xfrom
Copilot wants to merge 2 commits intorelease/bi-1.8.xfrom
Conversation
|
|
… JAVA_HOME Co-authored-by: kanushka <24244523+kanushka@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Check dependencies in Ballerina home for Java execution
Fix Java detection fallback when Ballerina dependencies directory is missing
Feb 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose
When the
dependenciesfolder is absent from the Ballerina home directory, Java detection fails immediately with an error rather than falling back toJAVA_HOMEor platform-specific locations.Goals
Implement a prioritized 3-step JDK lookup:
ballerinaHome/dependencies— check inside the active distribution firstbaseHome/dependencies— check one level up (sibling todistributions/)JAVA_HOME/ platform-specific system JDK — final fallbackApproach
Refactored
findHighestVersionJdk()inserver.tsinto three composable functions:findJdkInDirectory(directory)— pure directory scan, no fallback; returnsnullif dir missing or no matching JDK patternfindSystemJdk()— checksJAVA_HOME(with WSL support) and well-known platform paths (/usr/lib/jvm,ProgramFiles\Java, etc.)findHighestVersionJdk(directory)— backward-compatible wrapper:findJdkInDirectory(dir) ?? findSystemJdk()Both
getServerOptionsUsingJava(language server startup) andgetJavaCommand(debugger) now use the explicit 3-step chain:Previously,
findHighestVersionJdkreturnednullimmediately when the directory didn't exist — bypassing theJAVA_HOMEfallback entirely — and both callers threw an error without retrying alternative paths.UI Component Development
npm run storybookfrom the root directory to view current components.Manage Icons
User stories
Ballerina extension can now start the language server and debugger even when the bundled JDK (
dependencies/) is absent, usingJAVA_HOMEas a fallback — previously a hard failure.Release note
Fixed Java detection in the Ballerina extension: the extension now correctly falls back to
JAVA_HOMEwhen the Ballerinadependenciesdirectory does not exist.Documentation
N/A — internal runtime behavior change, no user-facing configuration change.
Training
N/A
Certification
N/A
Marketing
N/A
Automation tests
Security checks
Samples
N/A
Related PRs
N/A
Migrations (if applicable)
N/A
Test environment
Validated logic against the following scenarios on Linux:
.ballerina/distributions/ballerina-x.y.zinstall withdependencies/presentdependencies/folder withJAVA_HOMEsetballerinaHome/dependenciesLearning
N/A
Original prompt
🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.