List<WSLDistribution> () { if (!isSystemCompatible()) return Collections.emptyList(); final Path executableRoot = getExecutableRootPath(); if (executableRoot == null) return Collections.emptyList(); Collection<WslDistributionDescriptor> descriptors = WSLDistributionService.getInstance().getDescriptors(); final List<WSLDistribution> result = new ArrayList<>(descriptors.size() + 1 /* LEGACY_WSL */); for (WslDistributionDescriptor descriptor : descriptors) { String executablePathStr = descriptor.getExecutablePath(); if (executablePathStr != null) { Path executablePath = Paths.get(executablePathStr); if (!executablePath.isAbsolute()) { executablePath = executableRoot.resolve(executablePath); } if (Files.exists(executablePath, LinkOption.NOFOLLOW_LINKS)) { result.add(new WSLDistribution(descriptor, executablePath)); } } } // add legacy WSL if it's available and enabled if (Experiments.getInstance().isFeatureEnabled("wsl.legacy.distribution")) { ContainerUtil.addIfNotNull(result, WSLDistributionLegacy.getInstance()); } return result; }