[java] JrtFileSystem.isSupported() is always true

This commit is contained in:
Roman Shevchenko
2017-01-30 18:37:20 +03:00
parent aff2326b85
commit 87f93a7695
5 changed files with 10 additions and 42 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2016 JetBrains s.r.o.
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -301,8 +301,7 @@ public class JavaSdkImpl extends JavaSdk {
@Override
public boolean isValidSdkHome(String path) {
return checkForJdk(new File(path)) &&
(!JrtFileSystem.isModularJdk(path) || JrtFileSystem.isSupported());
return checkForJdk(new File(path));
}
@Override
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2016 JetBrains s.r.o.
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -87,7 +87,7 @@ public class JrtFileSystemImpl extends JrtFileSystem {
String homePath = extractLocalPath(extractRootPath(entryFile.getPath()));
ArchiveHandler handler = myHandlers.get(homePath);
if (handler == null) {
handler = isSupported() ? new JrtHandler(homePath) : new JrtHandlerStub(homePath);
handler = new JrtHandler(homePath);
myHandlers.put(homePath, handler);
ApplicationManager.getApplication().invokeLater(
() -> LocalFileSystem.getInstance().refreshAndFindFileByPath(homePath + "/release"),
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2016 JetBrains s.r.o.
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,7 +18,6 @@ package com.intellij.openapi.vfs.impl.jrt;
import com.intellij.openapi.util.SystemInfo;
import com.intellij.openapi.vfs.impl.ArchiveHandler;
import com.intellij.reference.SoftReference;
import com.intellij.util.ArrayUtil;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
@@ -117,22 +116,4 @@ class JrtHandler extends ArchiveHandler {
Path path = getFileSystem().getPath("/modules/" + relativePath);
return Files.readAllBytes(path);
}
}
class JrtHandlerStub extends ArchiveHandler {
public JrtHandlerStub(@NotNull String path) {
super(path);
}
@NotNull
@Override
protected Map<String, EntryInfo> createEntriesMap() {
return Collections.emptyMap();
}
@NotNull
@Override
public byte[] contentsToByteArray(@NotNull String relativePath) {
return ArrayUtil.EMPTY_BYTE_ARRAY;
}
}
@@ -16,24 +16,24 @@
package com.intellij.openapi.vfs;
import com.intellij.JavaTestUtil;
import com.intellij.openapi.util.SystemInfo;
import com.intellij.openapi.vfs.jrt.JrtFileSystem;
import com.intellij.testFramework.fixtures.BareTestFixtureTestCase;
import com.intellij.testFramework.rules.TempDirectory;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Rule;
import org.junit.Test;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.file.*;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assume.assumeTrue;
public class JrtFileSystemTest extends BareTestFixtureTestCase {
@Rule public TempDirectory myTempDir = new TempDirectory();
@@ -42,11 +42,6 @@ public class JrtFileSystemTest extends BareTestFixtureTestCase {
private Path myTempPath;
private VirtualFile myRoot;
@BeforeClass
public static void setUpClass() {
assumeTrue("skipped: java=" + SystemInfo.JAVA_VERSION, JrtFileSystem.isSupported());
}
@Before
public void setUp() throws IOException {
myTestData = Paths.get(JavaTestUtil.getJavaTestDataPath(), "jrt");
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2016 JetBrains s.r.o.
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
*/
package com.intellij.openapi.vfs.jrt;
import com.intellij.openapi.util.SystemInfo;
import com.intellij.openapi.vfs.StandardFileSystems;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.newvfs.ArchiveFileSystem;
@@ -29,12 +28,6 @@ public abstract class JrtFileSystem extends ArchiveFileSystem {
public static final String PROTOCOL_PREFIX = StandardFileSystems.JRT_PROTOCOL_PREFIX;
public static final String SEPARATOR = URLUtil.JAR_SEPARATOR;
private static final boolean SUPPORTED = SystemInfo.isJavaVersionAtLeast("1.8");
public static boolean isSupported() {
return SUPPORTED;
}
public static boolean isModularJdk(@NotNull String homePath) {
return new File(homePath, "lib/jrt-fs.jar").isFile() || new File(homePath, "jrt-fs.jar").isFile();
}