--- old/src/solaris/classes/sun/nio/fs/UnixPath.java 2012-06-25 21:56:16.000000000 -0700 +++ new/src/solaris/classes/sun/nio/fs/UnixPath.java 2012-06-25 21:56:16.000000000 -0700 @@ -68,7 +68,7 @@ UnixPath(UnixFileSystem fs, String input) { // removes redundant slashes and checks for invalid characters - this(fs, encode(normalizeAndCheck(input))); + this(fs, encode(fs, normalizeAndCheck(input))); } // package-private @@ -116,7 +116,7 @@ } // encodes the given path-string into a sequence of bytes - private static byte[] encode(String input) { + private static byte[] encode(UnixFileSystem fs, String input) { SoftReference ref = encoder.get(); CharsetEncoder ce = (ref != null) ? ref.get() : null; if (ce == null) { @@ -126,7 +126,7 @@ encoder.set(new SoftReference(ce)); } - char[] ca = input.toCharArray(); + char[] ca = fs.normalizeNativePath(input.toCharArray()); // size output buffer for worse-case size byte[] ba = new byte[(int)(ca.length * (double)ce.maxBytesPerChar())]; @@ -714,23 +714,7 @@ @Override public int compareTo(Path other) { - int len1 = path.length; - int len2 = ((UnixPath) other).path.length; - - int n = Math.min(len1, len2); - byte v1[] = path; - byte v2[] = ((UnixPath) other).path; - - int k = 0; - while (k < n) { - int c1 = v1[k] & 0xff; - int c2 = v2[k] & 0xff; - if (c1 != c2) { - return c1 - c2; - } - k++; - } - return len1 - len2; + return fs.comparePaths(this, (UnixPath) other); } @Override @@ -744,21 +728,18 @@ @Override public int hashCode() { // OK if two or more threads compute hash - int h = hash; - if (h == 0) { - for (int i = 0; i< path.length; i++) { - h = 31*h + (path[i] & 0xff); - } - hash = h; + if (hash == 0) { + hash = fs.hashCodePath(this); } - return h; + return hash; } @Override public String toString() { // OK if two or more threads create a String - if (stringValue == null) - stringValue = new String(path); // platform encoding + if (stringValue == null) { + stringValue = fs.normalizeJavaPath(new String(path)); // platform encoding + } return stringValue; }