You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
launching: Add file based configuration of installed JREs and EE defaults - #1047
Adds an optional JSON (JSONC) configuration file to provision Installed JREs and the default VM per Execution Environment at startup, for headless / managed / CI setups where editing the org.eclipse.jdt.launching.PREF_VM_XML preference string or writing a plugin for the vmInstalls extension point is impractical.
Activation (first match wins, all optional)
command line argument -jreConfig <file> (also -jreConfig=<file>)
system property -Dorg.eclipse.jdt.launching.jreConfig=<file>
environment variable JDT_JRE_CONFIG=<file>
Without any of these the code path is not entered and behaviour is unchanged. No API is added or changed; everything new is in org.eclipse.jdt.internal.launching.
File format
{
"java.configuration.runtimes": [
{
"label": "[JDK 21] Temurin 21.0.6+7-LTS", // required, VM name"path": "C:\\jdks\\temurin-21", // required, supports ${variable} substitution"version": "JavaSE-21", // optional, EE id used as fallback EE default"vendor": "Temurin", // optional, stored as VM attribute "vendor""sources": "C:\\jdks\\temurin-21\\lib\\src.zip", // optional, source attachment"javadoc": "https://docs.oracle.com/en/java/javase/21/docs/api/", // optional"vmArgs": "-Xmx2g", // optional"default": true// optional, workspace default JRE
}
],
"java.configuration.ee": [
{ "ee": "JavaSE-21", "path": "C:\\jdks\\temurin-21" }
]
}
The key names intentionally match the java.configuration.runtimes setting of the VS Code Java extension so existing files can be reused.
Semantics
Applied in JavaRuntime.initializeVMs() as step 2b (after persisted VMs, before Eclipse runtime detection): a runtime whose install location already exists in the container is updated in place (id kept), otherwise a VMStandin of the standard VM type is added. VMs are never removed, nothing is duplicated. Invalid locations are logged and skipped, never abort startup.
On a fresh workspace the first runtime (or the one flagged default) becomes the default JRE and compiler compliance is aligned, mirroring the existing runtime detection path.
EE defaults are applied in EnvironmentsManager.initializeDefaultVMs() after the persisted defaults: explicit java.configuration.ee entries override, a runtime version only fills environments that have no default yet. Incompatible VMs are logged and skipped.
JSON is read by a small dependency free parser (SimpleJsonParser, tolerates comments and trailing commas), avoiding a new bundle dependency.
Testing
JreConfigurationFileTests (added to AutomatedSuite): parser, config validation, container merge/update/default/skip-invalid. Passes via mvn -Pbuild-individual-bundles verify -pl org.eclipse.jdt.debug.tests -am -DtestClass=org.eclipse.jdt.debug.tests.core.JreConfigurationFileTests.
Headless Equinox run with the patched bundle and six real JDKs: fresh workspace, second start with modified file (rename in place, default switch, sources override, EE remap), no file (baseline unchanged), env variable activation.
With unchanged sources, a case-only change to an explicit library's Javadoc URL is discarded here. LibraryLocation.equals() uses LaunchingPlugin.sameURL(), which lowercases non-file URLs, so changing /API/ to /api/ leaves librariesChanged false. These paths can serve different content, and JREContainer uses the old explicit-library URL rather than the updated VM-level URL. Preserve case-sensitive URL changes in both this comparison and AbstractVMInstall.setLibraryLocations(), whose equality check would also discard the update. Add a regression test for a case-only URL change with unchanged sources.
For an existing VM with implicit libraries and a custom VM-level Javadoc URL, specifying only sources loads the type defaults here rather than the VM's effective libraries. Once these become explicit library locations, JREContainer.computeClasspathEntries() no longer applies the VM-level URL, so adding sources silently replaces or removes the existing documentation attachment. Use JavaRuntime.getLibraryLocations(standin) to preserve the effective Javadoc URL, and add a sources-only regression test.
For explicit libraries, a Javadoc URL change from /API/ to /api/ leaves projects using the old URL because LibraryLocation.equals() compares HTTP URLs case-insensitively. Preserve case-sensitive URL paths in both this comparison and the equality check used by AbstractVMInstall.setLibraryLocations(); changing this comparison alone will not make the setter accept the update. Add a regression test for a case-only Javadoc path change.
The parser accepts literal LF, TAB, and NUL characters inside strings, although JSON and JSONC require them to be escaped. Malformed configuration values therefore reach provisioning instead of producing a syntax error. Reject characters below U+0020 in this branch and add rejection tests, while continuing to allow their escaped forms.
Cover environment mapping precedence and compatibility
The new tests parse EE mappings but never exercise their application through EnvironmentsManager. Please add automated coverage for explicit mappings overriding persisted defaults, runtime version preserving an existing default, and incompatible VMs being rejected. ExecutionEnvironmentTests already exercises this manager; these new precedence and compatibility branches currently have no regression protection.
Validate runtime labels before setting EE defaults
A runtime rejected for an invalid label can still set an execution environment's default here when its path matches an already-installed compatible VM. For example, Temurin/JDK21 is logged as ignored by addVMs(), but its version still fills an unset default. Apply the same label validation in this fallback pass so that the rejected entry cannot change EE settings.
Done in 5fc0342: squashed the four commits into one and rebased onto master (f6084c4). Investigated the failing Jenkins test via the GitHub check output: testInvalidLabelIsSkipped assumed backslash is invalid on every OS, but Unix permits it in filenames. The assertion now follows the platform filename rule, matching the existing Installed JREs UI validation. Targeted Tycho build passes after the rebase: 12 tests, 0 failures/errors. CI will validate the Linux run. Unrelated local IDE import settings were not included.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Startup provisioning has an unresolved error-handling issue, and execution-environment selection lacks automated regression coverage needed for confidence without human validation.
Provision installed JREs and execution environment defaults from an optional JSON/JSONC file selected by command line, system property or environment variable. Merge existing installations without removing user VMs, preserve rename notifications and contributed VM ownership, and validate configured names and paths. Leave behavior unchanged when no configuration file is selected.
Preserve effective source and Javadoc attachments, including case-sensitive URL changes, and allow explicitly empty VM arguments to clear persisted values. Skip runtimes with malformed Javadoc URLs without discarding valid configuration and reject unescaped control characters.
Cover parsing, merging, contributions, renames, invalid paths and labels, attachment updates, and execution environment override, fallback and compatibility behavior with regression tests.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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
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.
Adds an optional JSON (JSONC) configuration file to provision Installed JREs and the default VM per Execution Environment at startup, for headless / managed / CI setups where editing the
org.eclipse.jdt.launching.PREF_VM_XMLpreference string or writing a plugin for thevmInstallsextension point is impractical.Activation (first match wins, all optional)
-jreConfig <file>(also-jreConfig=<file>)-Dorg.eclipse.jdt.launching.jreConfig=<file>JDT_JRE_CONFIG=<file>Without any of these the code path is not entered and behaviour is unchanged. No API is added or changed; everything new is in
org.eclipse.jdt.internal.launching.File format
{ "java.configuration.runtimes": [ { "label": "[JDK 21] Temurin 21.0.6+7-LTS", // required, VM name "path": "C:\\jdks\\temurin-21", // required, supports ${variable} substitution "version": "JavaSE-21", // optional, EE id used as fallback EE default "vendor": "Temurin", // optional, stored as VM attribute "vendor" "sources": "C:\\jdks\\temurin-21\\lib\\src.zip", // optional, source attachment "javadoc": "https://docs.oracle.com/en/java/javase/21/docs/api/", // optional "vmArgs": "-Xmx2g", // optional "default": true // optional, workspace default JRE } ], "java.configuration.ee": [ { "ee": "JavaSE-21", "path": "C:\\jdks\\temurin-21" } ] }The key names intentionally match the
java.configuration.runtimessetting of the VS Code Java extension so existing files can be reused.Semantics
JavaRuntime.initializeVMs()as step 2b (after persisted VMs, before Eclipse runtime detection): a runtime whose install location already exists in the container is updated in place (id kept), otherwise aVMStandinof the standard VM type is added. VMs are never removed, nothing is duplicated. Invalid locations are logged and skipped, never abort startup.default) becomes the default JRE and compiler compliance is aligned, mirroring the existing runtime detection path.EnvironmentsManager.initializeDefaultVMs()after the persisted defaults: explicitjava.configuration.eeentries override, a runtimeversiononly fills environments that have no default yet. Incompatible VMs are logged and skipped.SimpleJsonParser, tolerates comments and trailing commas), avoiding a new bundle dependency.Testing
JreConfigurationFileTests(added toAutomatedSuite): parser, config validation, container merge/update/default/skip-invalid. Passes viamvn -Pbuild-individual-bundles verify -pl org.eclipse.jdt.debug.tests -am -DtestClass=org.eclipse.jdt.debug.tests.core.JreConfigurationFileTests.