From 6afeb324861a3347604631edc0a7c50620e9e01d Mon Sep 17 00:00:00 2001 From: Alexander Koshevoy Date: Wed, 22 Oct 2025 19:42:31 +0200 Subject: [PATCH] [jps] IDEA-376790 Respect Eel machine when filtering SDKs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit SDK selection now accounts for the project's Eel environment rather than only WSL paths, so only SDKs runnable on the target machine are considered. When Eel is available, filtering uses compatibility checks against the project/Eel context to support generic non‑WSL remote setups. If the "wsl.use.remote.agent.for.nio.filesystem" registry key is `false`, WSL‑over‑Eel remains disabled and the legacy WslDistribution matching continues to be used. (cherry picked from commit 43723999a07be66da6fc6facda079c7a70b86fc8) IJ-CR-179667 GitOrigin-RevId: 72b304214d4c8361d64925eae3079012e78b27d2 --- .../compiler/server/BuildManager.java | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/java/compiler/impl/src/com/intellij/compiler/server/BuildManager.java b/java/compiler/impl/src/com/intellij/compiler/server/BuildManager.java index 7fadffa83db2..61d16ff604fe 100644 --- a/java/compiler/impl/src/com/intellij/compiler/server/BuildManager.java +++ b/java/compiler/impl/src/com/intellij/compiler/server/BuildManager.java @@ -151,7 +151,6 @@ import java.util.stream.Collectors; import static com.intellij.ide.impl.ProjectUtil.getProjectForComponent; import static com.intellij.openapi.diagnostic.InMemoryHandler.IN_MEMORY_LOGGER_ADVANCED_SETTINGS_NAME; import static com.intellij.platform.eel.provider.EelNioBridgeServiceKt.asEelPath; -import static com.intellij.platform.eel.provider.EelNioBridgeServiceKt.asNioPath; import static org.jetbrains.jps.api.CmdlineRemoteProto.Message.ControllerMessage.ParametersMessage.TargetTypeBuildScope; public final class BuildManager implements Disposable { @@ -1179,11 +1178,11 @@ public final class BuildManager implements Disposable { return getRuntimeSdk(project, MINIMUM_REQUIRED_JPS_BUILD_JAVA_VERSION, processed -> { // build's fallback SDK choosing policy: select among unprocessed SDKs in the SDK table the oldest possible one that can be used - // if project is located in a WSL VM, consider only SDKs, configured in the same WSL VM - Predicate wslSdkFilter = getWslSdkFilter(project); + // if the project is located within an Eel machine, consider only SDKs configured in the same Eel machine + Predicate sdkFilter = getSdkFilter(project); return StreamEx.of(ProjectJdkTable.getInstance().getSdksOfType(JavaSdk.getInstance())) - .filter(sdk -> !processed.contains(sdk) && wslSdkFilter.test(sdk)) + .filter(sdk -> !processed.contains(sdk) && sdkFilter.test(sdk)) .mapToEntry(sdk -> JavaVersion.tryParse(sdk.getVersionString())) .filterValues(version -> version != null && version.isAtLeast(MINIMUM_REQUIRED_JPS_BUILD_JAVA_VERSION)) .min(Map.Entry.comparingByValue()) @@ -1193,7 +1192,7 @@ public final class BuildManager implements Disposable { }); } - private static @NotNull Predicate getWslSdkFilter(@NotNull Project project) { + private static @NotNull Predicate getSdkFilter(@NotNull Project project) { // if WSL is configured, accepts only those SDKs that match project's WSL VM Supplier projectWslDistribution = new Supplier<>() { private Ref val; @@ -1203,7 +1202,13 @@ public final class BuildManager implements Disposable { return val != null? val.get() : (val = Ref.create(findWSLDistribution(project))).get(); } }; - return sdk -> Objects.equals(projectWslDistribution.get(), findWSLDistribution(sdk)); + if (canUseEel()) { + // an additional check for WSL distributions is required when "wsl.use.remote.agent.for.nio.filesystem" registry flag is set to false + return sdk -> JdkUtil.isCompatible(sdk, project) && Objects.equals(projectWslDistribution.get(), findWSLDistribution(sdk)); + } + else { + return sdk -> Objects.equals(projectWslDistribution.get(), findWSLDistribution(sdk)); + } } public static @NotNull Pair<@NotNull Sdk, @Nullable JavaSdkVersion> getJavacRuntimeSdk(@NotNull Project project) { @@ -1265,7 +1270,7 @@ public final class BuildManager implements Disposable { private static @Nullable Pair getForkedJavacFallbackSdk(@NotNull Project project, int oldestPossibleVersion) { // select the oldest SDK version among SDKs that are present in the SDK Table, but not older than return StreamEx.of(ProjectJdkTable.getInstance().getSdksOfType(JavaSdk.getInstance())) - .filter(getWslSdkFilter(project)) + .filter(getSdkFilter(project)) .mapToEntry(sdk -> JavaVersion.tryParse(sdk.getVersionString())) .filterValues(version -> version != null && version.isAtLeast(oldestPossibleVersion)) .min(Map.Entry.comparingByValue())