mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[java] moves modular runtime detection code to util class
This commit is contained in:
@@ -520,7 +520,7 @@ public class JavaSdkImpl extends JavaSdk {
|
||||
List<VirtualFile> result = ContainerUtil.newArrayList();
|
||||
VirtualFileManager fileManager = VirtualFileManager.getInstance();
|
||||
|
||||
if (JrtFileSystem.isModularJdk(file.getPath())) {
|
||||
if (JdkUtil.isModularRuntime(file)) {
|
||||
VirtualFile jrt = fileManager.findFileByUrl(JrtFileSystem.PROTOCOL_PREFIX + getPath(file) + JrtFileSystem.SEPARATOR);
|
||||
if (jrt != null) {
|
||||
ContainerUtil.addAll(result, jrt.getChildren());
|
||||
|
||||
@@ -18,6 +18,7 @@ package com.intellij.openapi.vfs.impl.jrt;
|
||||
import com.intellij.openapi.application.Application;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ModalityState;
|
||||
import com.intellij.openapi.projectRoots.JdkUtil;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
@@ -154,6 +155,6 @@ public class JrtFileSystemImpl extends JrtFileSystem {
|
||||
|
||||
@Override
|
||||
protected boolean isCorrectFileType(@NotNull VirtualFile local) {
|
||||
return isModularJdk(FileUtil.toSystemDependentName(local.getPath()));
|
||||
return JdkUtil.isModularRuntime(local.getPath());
|
||||
}
|
||||
}
|
||||
@@ -21,17 +21,11 @@ import com.intellij.openapi.vfs.newvfs.ArchiveFileSystem;
|
||||
import com.intellij.util.io.URLUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public abstract class JrtFileSystem extends ArchiveFileSystem {
|
||||
public static final String PROTOCOL = StandardFileSystems.JRT_PROTOCOL;
|
||||
public static final String PROTOCOL_PREFIX = StandardFileSystems.JRT_PROTOCOL_PREFIX;
|
||||
public static final String SEPARATOR = URLUtil.JAR_SEPARATOR;
|
||||
|
||||
public static boolean isModularJdk(@NotNull String homePath) {
|
||||
return new File(homePath, "lib/jrt-fs.jar").isFile();
|
||||
}
|
||||
|
||||
public static boolean isRoot(@NotNull VirtualFile file) {
|
||||
return file.getParent() == null && file.getFileSystem() instanceof JrtFileSystem;
|
||||
}
|
||||
|
||||
@@ -134,12 +134,20 @@ public class JdkUtil {
|
||||
public static boolean checkForRuntime(@NotNull String homePath) {
|
||||
return new File(homePath, "jre/lib/rt.jar").exists() || // JDK
|
||||
new File(homePath, "lib/rt.jar").exists() || // JRE
|
||||
new File(homePath, "lib/jrt-fs.jar").exists() || // Jigsaw JDK/JRE
|
||||
isModularRuntime(homePath) || // Jigsaw JDK/JRE
|
||||
new File(homePath, "../Classes/classes.jar").exists() || // Apple JDK
|
||||
new File(homePath, "jre/lib/vm.jar").exists() || // IBM JDK
|
||||
new File(homePath, "classes").isDirectory(); // custom build
|
||||
}
|
||||
|
||||
public static boolean isModularRuntime(@NotNull String homePath) {
|
||||
return isModularRuntime(new File(FileUtil.toSystemDependentName(homePath)));
|
||||
}
|
||||
|
||||
public static boolean isModularRuntime(@NotNull File homePath) {
|
||||
return new File(homePath, "lib/jrt-fs.jar").isFile();
|
||||
}
|
||||
|
||||
public static GeneralCommandLine setupJVMCommandLine(@NotNull SimpleJavaParameters javaParameters) throws CantRunException {
|
||||
Sdk jdk = javaParameters.getJdk();
|
||||
if (jdk == null) throw new CantRunException(ExecutionBundle.message("run.configuration.error.no.jdk.specified"));
|
||||
|
||||
Reference in New Issue
Block a user