< 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

*** 34,47 **** import java.util.Vector; import java.util.concurrent.ConcurrentHashMap; 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; /** * This class represents access to a file or directory. A FilePermission consists * of a pathname and a set of actions valid for that pathname. * <P> --- 34,47 ---- import java.util.Vector; import java.util.concurrent.ConcurrentHashMap; import jdk.internal.access.JavaIOFilePermissionAccess; import jdk.internal.access.SharedSecrets; 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 * of a pathname and a set of actions valid for that pathname. * <P>
*** 196,219 **** // return sb.toString(); // } 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:///")); ! private static final Path here = builtInFS.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(".."); /** * A private constructor that clones some and updates some, * always with a different name. * @param input --- 196,214 ---- // return sb.toString(); // } private static final long serialVersionUID = 7930732926638008763L; ! // 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 = FILE_SYSTEM.getPath( GetPropertyAction.privilegedGetProperty("user.dir")); ! 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, * always with a different name. * @param input
*** 324,334 **** this.mask = mask; if (name.equals("<<ALL FILES>>")) { allFiles = true; ! npath = builtInFS.getPath(""); // other fields remain default return; } boolean rememberStar = false; --- 319,329 ---- this.mask = mask; if (name.equals("<<ALL FILES>>")) { allFiles = true; ! npath = EMPTY_PATH; // other fields remain default return; } boolean rememberStar = false;
*** 339,365 **** } 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()) .normalize(); // lastName should always be non-null now Path lastName = npath.getFileName(); if (lastName != null && lastName.equals(DASH_PATH)) { directory = true; recursive = !rememberStar; npath = npath.getParent(); } if (npath == null) { ! npath = builtInFS.getPath(""); } 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-"); invalid = true; } } else { if ((cpath = getName()) == null) --- 334,360 ---- } try { // new File() can "normalize" some name, for example, "/C:/X" on // Windows. Some JDK codes generate such illegal names. ! npath = FILE_SYSTEM.getPath(new File(name).getPath()) .normalize(); // lastName should always be non-null now Path lastName = npath.getFileName(); if (lastName != null && lastName.equals(DASH_PATH)) { directory = true; recursive = !rememberStar; npath = npath.getParent(); } if (npath == null) { ! npath = EMPTY_PATH; } invalid = false; } catch (InvalidPathException ipe) { // Still invalid. For compatibility reason, accept it // but make this permission useless. ! npath = FILE_SYSTEM.getPath("-u-s-e-l-e-s-s-"); invalid = true; } } else { if ((cpath = getName()) == null)
< prev index next >