--- old/src/java.base/share/classes/java/io/FilePermission.java 2016-10-20 16:47:47.000000000 +0800 +++ new/src/java.base/share/classes/java/io/FilePermission.java 2016-10-20 16:47:47.000000000 +0800 @@ -173,6 +173,7 @@ private transient Path npath; // normalized dir path. private transient Path npath2; // alternative normalized dir path. private transient boolean allFiles; // whether this is <> + private transient boolean invalid; // whether input path is invalid // static Strings used by init(int mask) private static final char RECURSIVE_CHAR = '-'; @@ -223,6 +224,7 @@ this.npath = input.npath; this.actions = input.actions; this.allFiles = input.allFiles; + this.invalid = input.invalid; this.recursive = input.recursive; this.directory = input.directory; this.cpath = input.cpath; @@ -320,11 +322,12 @@ // Windows. Some JDK codes generate such illegal names. npath = builtInFS.getPath(new File(name).getPath()) .normalize(); + 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-"); - this.mask = NONE; + invalid = true; } // lastName should always be non-null now @@ -542,6 +545,12 @@ */ boolean impliesIgnoreMask(FilePermission that) { if (FilePermCompat.nb) { + if (this == that) { + return true; + } + if (this.invalid || that.invalid) { + return false; + } if (allFiles) { return true; } @@ -689,6 +698,9 @@ FilePermission that = (FilePermission) obj; if (FilePermCompat.nb) { + if (this.invalid || that.invalid) { + return false; + } return (this.mask == that.mask) && (this.allFiles == that.allFiles) && this.npath.equals(that.npath) && @@ -712,7 +724,7 @@ public int hashCode() { if (FilePermCompat.nb) { return Objects.hash( - mask, allFiles, directory, recursive, npath, npath2); + mask, allFiles, directory, recursive, npath, npath2, invalid); } else { return 0; }