--- old/src/java.base/share/classes/java/io/FilePermission.java 2018-11-09 05:51:29.845874809 -0800 +++ new/src/java.base/share/classes/java/io/FilePermission.java 2018-11-09 05:51:29.541875027 -0800 @@ -36,10 +36,10 @@ import jdk.internal.access.JavaIOFilePermissionAccess; import jdk.internal.access.SharedSecrets; -import sun.nio.fs.DefaultFileSystemProvider; import sun.security.action.GetPropertyAction; import sun.security.util.FilePermCompat; import sun.security.util.SecurityConstants; +import static sun.nio.fs.DefaultFileSystemProvider.FILE_SYSTEM; /** * This class represents access to a file or directory. A FilePermission consists @@ -198,20 +198,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. - */ - private static final java.nio.file.FileSystem builtInFS = - DefaultFileSystemProvider.create() - .getFileSystem(URI.create("file:///")); + // Always use the internal default file system, in case it was modified + // with the java.nio.file.spi.DefaultFileSystemProvider system property. - private static final Path here = builtInFS.getPath( + private static final Path here = FILE_SYSTEM.getPath( GetPropertyAction.privilegedGetProperty("user.dir")); - private static final Path EMPTY_PATH = builtInFS.getPath(""); - private static final Path DASH_PATH = builtInFS.getPath("-"); - private static final Path DOTDOT_PATH = builtInFS.getPath(".."); + private static final Path EMPTY_PATH = FILE_SYSTEM.getPath(""); + private static final Path DASH_PATH = FILE_SYSTEM.getPath("-"); + private static final Path DOTDOT_PATH = FILE_SYSTEM.getPath(".."); /** * A private constructor that clones some and updates some, @@ -326,7 +321,7 @@ if (name.equals("<>")) { allFiles = true; - npath = builtInFS.getPath(""); + npath = EMPTY_PATH; // other fields remain default return; } @@ -341,7 +336,7 @@ try { // new File() can "normalize" some name, for example, "/C:/X" on // Windows. Some JDK codes generate such illegal names. - npath = builtInFS.getPath(new File(name).getPath()) + npath = FILE_SYSTEM.getPath(new File(name).getPath()) .normalize(); // lastName should always be non-null now Path lastName = npath.getFileName(); @@ -351,13 +346,13 @@ 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. - npath = builtInFS.getPath("-u-s-e-l-e-s-s-"); + npath = FILE_SYSTEM.getPath("-u-s-e-l-e-s-s-"); invalid = true; }