8154403: JRT filesystem loaded by JDK8 with URLClassLoader is not closable since JDK-8147460
authorsherman
Mon, 18 Apr 2016 10:57:11 -0700
changeset 37516 66a0579e606c
parent 37396 8d78fb40648d
child 37517 9b2bc238b8a3
8154403: JRT filesystem loaded by JDK8 with URLClassLoader is not closable since JDK-8147460 Reviewed-by: alanb
jdk/src/java.base/share/classes/jdk/internal/jrtfs/JrtFileSystemProvider.java
jdk/test/jdk/internal/jrtfs/WithSecurityManager.java
jdk/test/jdk/internal/jrtfs/remote/Main.java
jdk/test/jdk/internal/jrtfs/remote/RemoteRuntimeImageTest.java
--- a/jdk/src/java.base/share/classes/jdk/internal/jrtfs/JrtFileSystemProvider.java	Wed Jul 05 21:36:10 2017 +0200
+++ b/jdk/src/java.base/share/classes/jdk/internal/jrtfs/JrtFileSystemProvider.java	Mon Apr 18 10:57:11 2016 -0700
@@ -101,10 +101,10 @@
     @Override
     public FileSystem newFileSystem(URI uri, Map<String, ?> env)
             throws IOException {
+        Objects.requireNonNull(env);
         checkPermission();
         checkUri(uri);
-
-        if (env != null && env.containsKey("java.home")) {
+        if (env.containsKey("java.home")) {
             return newFileSystem((String)env.get("java.home"), uri, env);
         } else {
             return new JrtFileSystem(this, env);
--- a/jdk/test/jdk/internal/jrtfs/WithSecurityManager.java	Wed Jul 05 21:36:10 2017 +0200
+++ b/jdk/test/jdk/internal/jrtfs/WithSecurityManager.java	Mon Apr 18 10:57:11 2016 -0700
@@ -31,6 +31,7 @@
 import java.nio.file.FileSystems;
 import java.nio.file.Path;
 import java.nio.file.Paths;
+import java.util.Collections;
 
 public class WithSecurityManager {
     public static void main(String[] args) throws Exception {
@@ -61,7 +62,7 @@
 
         // check FileSystems.newFileSystem
         try {
-            FileSystems.newFileSystem(URI.create("jrt:/"), null);
+            FileSystems.newFileSystem(URI.create("jrt:/"), Collections.emptyMap());
             if (!allow) throw new RuntimeException("access not expected");
         } catch (SecurityException se) {
             if (allow)
--- a/jdk/test/jdk/internal/jrtfs/remote/Main.java	Wed Jul 05 21:36:10 2017 +0200
+++ b/jdk/test/jdk/internal/jrtfs/remote/Main.java	Mon Apr 18 10:57:11 2016 -0700
@@ -30,6 +30,7 @@
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
+import java.util.Collections;
 import java.util.stream.Stream;
 
 /**
@@ -69,11 +70,12 @@
     private static FileSystem createFsWithURLClassloader(String javaHome) throws IOException{
         URL url = Paths.get(javaHome, "jrt-fs.jar").toUri().toURL();
         URLClassLoader loader = new URLClassLoader(new URL[] { url });
-        return FileSystems.newFileSystem(URI.create("jrt:/"), null, loader);
+        return FileSystems.newFileSystem(URI.create("jrt:/"),
+                                                    Collections.emptyMap(),
+                                                    loader);
     }
 
     private static FileSystem createFsByInstalledProvider() throws IOException {
         return FileSystems.getFileSystem(URI.create("jrt:/"));
     }
 }
-
--- a/jdk/test/jdk/internal/jrtfs/remote/RemoteRuntimeImageTest.java	Wed Jul 05 21:36:10 2017 +0200
+++ b/jdk/test/jdk/internal/jrtfs/remote/RemoteRuntimeImageTest.java	Mon Apr 18 10:57:11 2016 -0700
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 8141609
+ * @bug 8141609 8154403
  * @summary Verify JDK 8 can use jrt-fs.jar to work with jrt file system.
  * @run main RemoteRuntimeImageTest
  */
@@ -63,7 +63,6 @@
 
         String java = jdk8Path.resolve("bin/java").toAbsolutePath().toString();
         String javac = jdk8Path.resolve("bin/javac").toAbsolutePath().toString();
-
         Files.createDirectories(Paths.get(".", CLASSES_DIR));
         String jrtJar = Paths.get(TEST_JAVAHOME, JRTFS_JAR).toAbsolutePath().toString();
 
@@ -121,4 +120,3 @@
         return version.startsWith("\"1.8");
     }
 }
-