< prev index next >

src/java.base/share/classes/java/io/FilePermission.java

Print this page
8213406: (fs) More than one instance of built-in FileSystem observed in heap
Reviewed-by: alanb, cushon, weijun

@@ -23,11 +23,10 @@
  * questions.
  */
 
 package java.io;
 
-import java.net.URI;
 import java.nio.file.*;
 import java.security.*;
 import java.util.Enumeration;
 import java.util.Objects;
 import java.util.StringJoiner;

@@ -197,16 +196,15 @@
 //    }
 
     private static final long serialVersionUID = 7930732926638008763L;
 
     /**
-     * Always use the internal default file system, in case it was modified
-     * with java.nio.file.spi.DefaultFileSystemProvider.
+     * Use the platform's default file system to avoid recursive initialization
+     * issues when the VM is configured to use a custom file system provider.
      */
     private static final java.nio.file.FileSystem builtInFS =
-            DefaultFileSystemProvider.create()
-                    .getFileSystem(URI.create("file:///"));
+        DefaultFileSystemProvider.theFileSystem();
 
     private static final Path here = builtInFS.getPath(
             GetPropertyAction.privilegedGetProperty("user.dir"));
 
     private static final Path EMPTY_PATH = builtInFS.getPath("");

@@ -324,11 +322,11 @@
 
             this.mask = mask;
 
             if (name.equals("<<ALL FILES>>")) {
                 allFiles = true;
-                npath = builtInFS.getPath("");
+                npath = EMPTY_PATH;
                 // other fields remain default
                 return;
             }
 
             boolean rememberStar = false;

@@ -349,11 +347,11 @@
                     directory = true;
                     recursive = !rememberStar;
                     npath = npath.getParent();
                 }
                 if (npath == null) {
-                    npath = builtInFS.getPath("");
+                    npath = EMPTY_PATH;
                 }
                 invalid = false;
             } catch (InvalidPathException ipe) {
                 // Still invalid. For compatibility reason, accept it
                 // but make this permission useless.
< prev index next >