From eac7657b2a51d22028d152f75a4e1cc9eae0174b Mon Sep 17 00:00:00 2001 From: Snjezana Peco Date: Tue, 9 Dec 2025 20:25:19 +0100 Subject: [PATCH] Fix JvmConfigurator --- .../eclipse/core/model/discovery/JvmConfigurator.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/bundles/com.salesforce.bazel.eclipse.core/src/com/salesforce/bazel/eclipse/core/model/discovery/JvmConfigurator.java b/bundles/com.salesforce.bazel.eclipse.core/src/com/salesforce/bazel/eclipse/core/model/discovery/JvmConfigurator.java index 0376f4f2..e784fda8 100644 --- a/bundles/com.salesforce.bazel.eclipse.core/src/com/salesforce/bazel/eclipse/core/model/discovery/JvmConfigurator.java +++ b/bundles/com.salesforce.bazel.eclipse.core/src/com/salesforce/bazel/eclipse/core/model/discovery/JvmConfigurator.java @@ -165,7 +165,7 @@ public IVMInstall configureVMInstall(java.nio.file.Path resolvedJavaHomePath, Ba getPrefix(vmType), resolvedJavaHomePath.getFileName().toString(), bazelWorkspace.getName()); - var vm = findVmForNameOrPath(resolvedJavaHomePath, name); + var vm = findVmForNameOrPath(resolvedJavaHomePath, name, bazelWorkspace, vmType); // delete if location or other attributes don't not match if ((vm instanceof AbstractVMInstall realVm) && (!vm.getInstallLocation().toPath().equals(resolvedJavaHomePath) @@ -239,12 +239,19 @@ private void enablePreviewIfPossible(IJavaProject javaProject, String version) { } } - private IVMInstall findVmForNameOrPath(java.nio.file.Path javaHome, String name) { + private IVMInstall findVmForNameOrPath(java.nio.file.Path javaHome, String name, BazelWorkspace bazelWorkspace, + String vmType) { var file = javaHome.toFile(); var types = JavaRuntime.getVMInstallTypes(); for (IVMInstallType type : types) { var installs = type.getVMInstalls(); for (IVMInstall install : installs) { + if (!(install instanceof AbstractVMInstall realVm) + || !bazelWorkspace.getLocation().toString().equals(realVm.getAttribute(VM_ATTR_WORKSPACE)) + || !vmType.equals(realVm.getAttribute(VM_ATTR_TYPE))) { + continue; + } + if ((name != null) && name.equals(install.getName())) { return install; }