Initial load
diff --git a/test/java/io/pathNames/General.java b/test/java/io/pathNames/General.java
new file mode 100644
index 0000000..780426d
--- /dev/null
+++ b/test/java/io/pathNames/General.java
@@ -0,0 +1,358 @@
+/*
+ * Copyright 1998-2000 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+   @summary Common definitions for general exhaustive pathname tests
+   @author  Mark Reinhold
+ */
+
+import java.io.*;
+import java.util.*;
+
+
+public class General {
+
+    public static boolean debug = false;
+
+    private static boolean win32 = (File.separatorChar == '\\');
+
+    private static int gensymCounter = 0;
+
+
+    /* Generate a filename unique to this run */
+    private static String gensym() {
+        return "x." + ++gensymCounter;
+    }
+
+
+    /**
+     * Find a file in the given subdirectory, or descend into further
+     * subdirectories, if any, if no file is found here.  Return null if no
+     * file can be found anywhere beneath the given subdirectory.
+     * @param  dir     Directory at which we started
+     * @param  subdir  Subdirectory that we're exploring
+     * @param  dl      Listing of subdirectory
+     */
+    private static String findSomeFile(String dir, String subdir, String[] dl) {
+        for (int i = 0; i < dl.length; i++) {
+            File f = new File(subdir, dl[i]);
+            File df = new File(dir, f.getPath());
+            if (df.exists() && df.isFile()) {
+                return f.getPath();
+            }
+        }
+        for (int i = 0; i < dl.length; i++) {
+            File f = (subdir.length() == 0) ? new File(dl[i])
+                                            : new File(subdir, dl[i]);
+            File df = new File(dir, f.getPath());
+            if (df.exists() && df.isDirectory()) {
+                String[] dl2 = df.list();
+                if (dl2 != null) {
+                    String ff = findSomeFile(dir, f.getPath(), dl2);
+                    if (ff != null) return ff;
+                }
+            }
+        }
+        return null;
+    }
+
+
+    /**
+     * Construct a string that names a file in the given directory.  If create
+     * is true, then create a file if none is found, and throw an exception if
+     * that is not possible; otherwise, return null if no file can be found.
+     */
+    private static String findSomeFile(String dir, boolean create) {
+        File d = new File(dir);
+        String[] dl = d.list();
+        if (dl == null) {
+            throw new RuntimeException("Can't list " + dir);
+        }
+        for (int i = 0; i < dl.length; i++) {
+            File f = new File(dir, dl[i]);
+            if (f.isFile()) {
+                return dl[i];
+            }
+        }
+        String f = findSomeFile(dir, "", dl);
+        if (f != null) {
+            return f;
+        }
+        if (create) {
+            File nf = new File(d, gensym());
+            OutputStream os;
+            try {
+                os = new FileOutputStream(nf);
+                os.close();
+            } catch (IOException x) {
+                throw new RuntimeException("Can't create a file in " + dir);
+            }
+            return nf.getName();
+        }
+        return null;
+    }
+
+
+    /**
+     * Construct a string that names a subdirectory of the given directory.
+     * If create is true, then create a subdirectory if none is found, and
+     * throw an exception if that is not possible; otherwise, return null if
+     * no subdirectory can be found.
+     */
+    private static String findSomeDir(String dir, boolean create) {
+        File d = new File(dir);
+        String[] dl = d.list();
+        if (dl == null) {
+            throw new RuntimeException("Can't list " + dir);
+        }
+        for (int i = 0; i < dl.length; i++) {
+            File f = new File(d, dl[i]);
+            if (f.isDirectory() && f.canRead()) {
+                String[] dl2 = f.list();
+                if (dl2.length >= 250) {
+                    /* Heuristic to avoid scanning huge directories */
+                    continue;
+                }
+                return dl[i];
+            }
+        }
+        if (create) {
+            File sd = new File(d, gensym());
+            if (sd.mkdir()) return sd.getName();
+        }
+        return null;
+    }
+
+
+    /** Construct a string that does not name a file in the given directory */
+    private static String findNon(String dir) {
+        File d = new File(dir);
+        String[] x = new String[] { "foo", "bar", "baz" };
+        for (int i = 0; i < x.length; i++) {
+            File f = new File(d, x[i]);
+            if (!f.exists()) {
+                return x[i];
+            }
+        }
+        for (int i = 0; i < 1024; i++) {
+            String n = "xx" + Integer.toString(i);
+            File f = new File(d, n);
+            if (!f.exists()) {
+                return n;
+            }
+        }
+        throw new RuntimeException("Can't find a non-existent file in " + dir);
+    }
+
+
+    /** Ensure that the named file does not exist */
+    public static void ensureNon(String fn) {
+        if ((new File(fn)).exists()) {
+            throw new RuntimeException("Test path " + fn + " exists");
+        }
+    }
+
+
+    /** Tell whether the given character is a "slash" on this platform */
+    private static boolean isSlash(char x) {
+        if (x == File.separatorChar) return true;
+        if (win32 && (x == '/')) return true;
+        return false;
+    }
+
+
+    /**
+     * Trim trailing slashes from the given string, but leave singleton slashes
+     * alone (they denote root directories)
+     */
+    private static String trimTrailingSlashes(String s) {
+        int n = s.length();
+        if (n == 0) return s;
+        n--;
+        while ((n > 0) && isSlash(s.charAt(n))) {
+            if ((n >= 1) && s.charAt(n - 1) == ':') break;
+            n--;
+        }
+        return s.substring(0, n + 1);
+    }
+
+
+    /** Concatenate two paths, trimming slashes as needed */
+    private static String pathConcat(String a, String b) {
+        if (a.length() == 0) return b;
+        if (b.length() == 0) return a;
+        if (isSlash(a.charAt(a.length() - 1))
+            || isSlash(b.charAt(0))
+            || (win32 && (a.charAt(a.length() - 1) == ':'))) {
+            return a + b;
+        } else {
+            return a + File.separatorChar + b;
+        }
+    }
+
+
+
+    /** Hash table of input pathnames, used to detect duplicates */
+    private static Hashtable checked = new Hashtable();
+
+    /**
+     * Check the given pathname.  Its canonical pathname should be the given
+     * answer.  If the path names a file that exists and is readable, then
+     * FileInputStream and RandomAccessFile should both be able to open it.
+     */
+    public static void check(String answer, String path) throws IOException {
+        String ans = trimTrailingSlashes(answer);
+        if (path.length() == 0) return;
+        if (checked.get(path) != null) {
+            System.err.println("DUP " + path);
+            return;
+        }
+        checked.put(path, path);
+
+        String cpath;
+        try {
+            File f = new File(path);
+            cpath = f.getCanonicalPath();
+            if (f.exists() && f.isFile() && f.canRead()) {
+                InputStream in = new FileInputStream(path);
+                in.close();
+                RandomAccessFile raf = new RandomAccessFile(path, "r");
+                raf.close();
+            }
+        } catch (IOException x) {
+            System.err.println(ans + " <-- " + path + " ==> " + x);
+            if (debug) return;
+            else throw x;
+        }
+        if (cpath.equals(ans)) {
+            System.err.println(ans + " <== " + path);
+        } else {
+            System.err.println(ans + " <-- " + path + " ==> " + cpath + " MISMATCH");
+            if (!debug) {
+                throw new RuntimeException("Mismatch: " + path + " ==> " + cpath +
+                                           ", should be " + ans);
+            }
+        }
+    }
+
+
+
+    /*
+     * The following three mutually-recursive methods generate and check a tree
+     * of filenames of arbitrary depth.  Each method has (at least) these
+     * arguments:
+     *
+     *     int depth         Remaining tree depth
+     *     boolean create    Controls whether test files and directories
+     *                       will be created as needed
+     *     String ans        Expected answer for the check method (above)
+     *     String ask        Input pathname to be passed to the check method
+     */
+
+
+    /** Check a single slash case, plus its children */
+    public static void checkSlash(int depth, boolean create,
+                                  String ans, String ask, String slash)
+        throws Exception
+    {
+        check(ans, ask + slash);
+        checkNames(depth, create,
+                   ans.endsWith(File.separator) ? ans : ans + File.separator,
+                   ask + slash);
+    }
+
+
+    /** Check slash cases for the given ask string */
+    public static void checkSlashes(int depth, boolean create,
+                                    String ans, String ask)
+        throws Exception
+    {
+        check(ans, ask);
+        if (depth == 0) return;
+
+        checkSlash(depth, create, ans, ask, "/");
+        checkSlash(depth, create, ans, ask, "//");
+        checkSlash(depth, create, ans, ask, "///");
+        if (win32) {
+            checkSlash(depth, create, ans, ask, "\\");
+            checkSlash(depth, create, ans, ask, "\\\\");
+            checkSlash(depth, create, ans, ask, "\\/");
+            checkSlash(depth, create, ans, ask, "/\\");
+            checkSlash(depth, create, ans, ask, "\\\\\\");
+        }
+    }
+
+
+    /** Check name cases for the given ask string */
+    public static void checkNames(int depth, boolean create,
+                                  String ans, String ask)
+        throws Exception
+    {
+        int d = depth - 1;
+        File f = new File(ans);
+        String n;
+
+        /* Normal name */
+        if (f.exists()) {
+            if (f.isDirectory() && f.canRead()) {
+                if ((n = findSomeFile(ans, create)) != null)
+                    checkSlashes(d, create, ans + n, ask + n);
+                if ((n = findSomeDir(ans, create)) != null)
+                    checkSlashes(d, create, ans + n, ask + n);
+            }
+            n = findNon(ans);
+            checkSlashes(d, create, ans + n, ask + n);
+        } else {
+            n = "foo" + depth;
+            checkSlashes(d, create, ans + n, ask + n);
+        }
+
+        /* "." */
+        checkSlashes(d, create, trimTrailingSlashes(ans), ask + ".");
+
+        /* ".." */
+        if ((n = f.getParent()) != null) {
+            String n2;
+            if (win32
+                && ((n2 = f.getParentFile().getParent()) != null)
+                && n2.equals("\\\\")) {
+                /* Win32 resolves \\foo\bar\.. to \\foo\bar */
+                checkSlashes(d, create, ans, ask + "..");
+            } else {
+                checkSlashes(d, create, n, ask + "..");
+            }
+        }
+        else {
+            if (win32)
+                checkSlashes(d, create, ans, ask + "..");
+            else {
+                // Fix for 4237875. We must ensure that we are sufficiently
+                // deep in the path hierarchy to test parents this high up
+                File thisPath = new File(ask);
+                File nextPath = new File(ask + "..");
+                if (!thisPath.getCanonicalPath().equals(nextPath.getCanonicalPath()))
+                    checkSlashes(d, create, ans + "..", ask + "..");
+            }
+        }
+    }
+}
diff --git a/test/java/io/pathNames/GeneralWin32.java b/test/java/io/pathNames/GeneralWin32.java
new file mode 100644
index 0000000..0242402
--- /dev/null
+++ b/test/java/io/pathNames/GeneralWin32.java
@@ -0,0 +1,176 @@
+/*
+ * Copyright 1998-2003 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/* @test
+   @bug 4032066 4039597 4046914 4054511 4065189 4109131 4875229
+   @summary General exhaustive test of win32 pathname handling
+   @author Mark Reinhold
+
+   @build General GeneralWin32
+   @run main/timeout=600 GeneralWin32
+ */
+
+import java.io.*;
+import java.util.*;
+
+
+public class GeneralWin32 extends General {
+
+
+    /**
+     * Hardwired UNC pathnames used for testing
+     *
+     * This test attempts to use the host and share names defined in this class
+     * to test UNC pathnames.  The test will not fail if the host or share
+     * don't exist, but it will print a warning saying that it was unable to
+     * test UNC pathnames completely.
+     */
+    private static final String EXISTENT_UNC_HOST = "pc-cup01";
+    private static final String EXISTENT_UNC_SHARE = "pcdist";
+    private static final String NONEXISTENT_UNC_HOST = "non-existent-unc-host";
+    private static final String NONEXISTENT_UNC_SHARE = "bogus-share";
+
+
+    /* Pathnames relative to working directory */
+
+    private static void checkCaseLookup(String ud) throws IOException {
+        /* Use long names here to avoid 8.3 format, which Samba servers often
+           force to lowercase */
+        File d = new File("XyZzY0123", "FOO_bar_BAZ");
+        File f = new File(d, "GLORPified");
+        if (!f.exists()) {
+            if (!d.exists()) {
+                if (!d.mkdirs()) {
+                    throw new RuntimeException("Can't create directory " + d);
+                }
+            }
+            OutputStream o = new FileOutputStream(f);
+            o.close();
+        }
+        File f2 = new File(d.getParent(), "mumble"); /* For later ud tests */
+        if (!f2.exists()) {
+            OutputStream o = new FileOutputStream(f2);
+            o.close();
+        }
+
+        /* Computing the canonical path of a Win32 file should expose the true
+           case of filenames, rather than just using the input case */
+        File y = new File(ud, f.getPath());
+        String ans = y.getPath();
+        check(ans, "XyZzY0123\\FOO_bar_BAZ\\GLORPified");
+        check(ans, "xyzzy0123\\foo_bar_baz\\glorpified");
+        check(ans, "XYZZY0123\\FOO_BAR_BAZ\\GLORPIFIED");
+    }
+
+    private static void checkWild(File f) throws Exception {
+        try {
+            f.getCanonicalPath();
+        } catch (IOException x) {
+            return;
+        }
+        throw new Exception("Wildcard path not rejected: " + f);
+    }
+
+    private static void checkWildCards(String ud) throws Exception {
+        File d = new File(ud).getCanonicalFile();
+        checkWild(new File(d, "*.*"));
+        checkWild(new File(d, "*.???"));
+        checkWild(new File(new File(d, "*.*"), "foo"));
+    }
+
+    private static void checkRelativePaths() throws Exception {
+        String ud = System.getProperty("user.dir").replace('/', '\\');
+        checkCaseLookup(ud);
+        checkWildCards(ud);
+        checkNames(3, true, ud + "\\", "");
+    }
+
+
+    /* Pathnames with drive specifiers */
+
+    private static char findInactiveDrive() {
+        for (char d = 'Z'; d >= 'E'; d--) {
+            File df = new File(d + ":\\");
+            if (!df.exists()) {
+                return d;
+            }
+        }
+        throw new RuntimeException("Can't find an inactive drive");
+    }
+
+    private static char findActiveDrive() {
+        for (char d = 'C'; d <= 'Z'; d--) {
+            File df = new File(d + ":\\");
+            if (df.exists()) return d;
+        }
+        throw new RuntimeException("Can't find an active drive");
+    }
+
+    private static void checkDrive(int depth, char drive, boolean exists)
+        throws Exception
+    {
+        String d = drive + ":";
+        File df = new File(d);
+        String ans = exists ? df.getAbsolutePath() : d;
+        if (!ans.endsWith("\\"))
+            ans = ans + "\\";
+        checkNames(depth, false, ans, d);
+    }
+
+    private static void checkDrivePaths() throws Exception {
+        checkDrive(2, findActiveDrive(), true);
+        checkDrive(2, findInactiveDrive(), false);
+    }
+
+
+    /* UNC pathnames */
+
+    private static void checkUncPaths() throws Exception {
+        String s = ("\\\\" + NONEXISTENT_UNC_HOST
+                    + "\\" + NONEXISTENT_UNC_SHARE);
+        ensureNon(s);
+        checkSlashes(2, false, s, s);
+
+        s = "\\\\" + EXISTENT_UNC_HOST + "\\" + EXISTENT_UNC_SHARE;
+        if (!(new File(s)).exists()) {
+            System.err.println("WARNING: " + s +
+                               " does not exist, unable to test UNC pathnames");
+            return;
+        }
+
+        checkSlashes(2, false, s, s);
+    }
+
+
+    public static void main(String[] args) throws Exception {
+        if (File.separatorChar != '\\') {
+            /* This test is only valid on win32 systems */
+            return;
+        }
+        if (args.length > 0) debug = true;
+        checkRelativePaths();
+        checkDrivePaths();
+        checkUncPaths();
+    }
+
+}
diff --git a/test/java/io/pathNames/unix/TrailingSlash.java b/test/java/io/pathNames/unix/TrailingSlash.java
new file mode 100644
index 0000000..0866ff9
--- /dev/null
+++ b/test/java/io/pathNames/unix/TrailingSlash.java
@@ -0,0 +1,124 @@
+/*
+ * Copyright 2001 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/* @test
+ * @bug 4427862
+ * @summary Ensure that trailing slashes are ignored when opening files
+ */
+
+import java.io.*;
+
+
+public class TrailingSlash {
+
+    static PrintStream log = System.err;
+    static int failures = 0;
+
+    static void check(String what, String fns,
+                      boolean expected, boolean threw)
+    {
+        if (expected == threw) {
+            log.println("    FAIL: new " + what + "(\"" + fns + "\") "
+                        + (expected ? "failed" : "succeeded"));
+            failures++;
+        }
+    }
+
+    static void go(String fns, boolean fis, boolean raf, boolean fos)
+        throws IOException
+    {
+        boolean threw;
+
+        threw = false;
+        try {
+            new FileInputStream(fns).close();
+            log.println("    FileInputStream okay");
+        } catch (IOException x) {
+            log.println("    FileInputStream: " + x);
+            threw = true;
+        }
+        check("FileInputStream", fns, fis, threw);
+
+        threw = false;
+        try {
+            new RandomAccessFile(fns, "r").close();
+            log.println("    RandomAccessFile okay");
+        } catch (IOException x) {
+            log.println("    RandomAccessFile: " + x);
+            threw = true;
+        }
+        check("RandomAccessFile", fns, raf, threw);
+
+        threw = false;
+        try {
+            new FileOutputStream(fns).close();
+            log.println("    FileOutputStream okay");
+        } catch (IOException x) {
+            log.println("    FileOutputStream: " + x);
+            threw = true;
+        }
+        check("FileOutputStream", fns, fos, threw);
+
+    }
+
+    static void go(String fn, String fns) throws Exception {
+
+        log.println("Test case: " + fns);
+
+        File f = new File(fn);
+
+        f.delete();
+        if (f.exists())
+            throw new Exception("Can't delete " + f);
+
+        log.println("  " + fn + " does not exist");
+        go(fns, false, false, true);
+
+        f.delete();
+        f.mkdir();
+        log.println("  " + fn + " is a directory");
+        go(fns, false, false, false);
+
+        f.delete();
+        f.createNewFile();
+        log.println("  " + fn + " is a file");
+        go(fns, true, true, true);
+
+    }
+
+    public static void main(String[] args) throws Exception {
+        if (File.separatorChar != '/') {
+            // This test is only valid on Unix systems
+            return;
+        }
+
+        go("xyzzy", "xyzzy");
+        go("xyzzy", "xyzzy/");
+        go("xyzzy", "xyzzy//");
+
+        if (failures > 0)
+            throw new Exception(failures + " failures");
+
+    }
+
+}
diff --git a/test/java/io/pathNames/win32/BadDriveLetter.java b/test/java/io/pathNames/win32/BadDriveLetter.java
new file mode 100644
index 0000000..6728e6d
--- /dev/null
+++ b/test/java/io/pathNames/win32/BadDriveLetter.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright 1998 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/* @test
+   @bug 4138774
+   @summary Make sure that a bad drive letter doesn't cause an exception
+ */
+
+public class BadDriveLetter {
+
+    public static void main(String[] args) {
+        System.err.println(new java.io.File(".:").getAbsolutePath());
+    }
+
+}
diff --git a/test/java/io/pathNames/win32/DriveOnly.java b/test/java/io/pathNames/win32/DriveOnly.java
new file mode 100644
index 0000000..4156294
--- /dev/null
+++ b/test/java/io/pathNames/win32/DriveOnly.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright 1998 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/* @test
+   @bug 4096648
+   @summary Make sure that isDirectory and lastModified work on "x:"
+ */
+
+import java.io.File;
+
+
+public class DriveOnly {
+
+    public static void main(String[] args) throws Exception {
+        if (File.separatorChar != '\\') return;
+        File f = new File("").getCanonicalFile();
+        while (f.getParent() != null) f = f.getParentFile();
+        String p = f.getPath().substring(0, 2);
+        if (!(Character.isLetter(p.charAt(0)) && (p.charAt(1) == ':'))) {
+            System.err.println("No current drive, cannot run test");
+            return;
+        }
+        f = new File(p);
+        if (!f.isDirectory())
+            throw new Exception("\"" + f + "\" is not a directory");
+        if (f.lastModified() == 0)
+            throw new Exception("\"" + f + "\" has no last-modified time");
+    }
+
+}
diff --git a/test/java/io/pathNames/win32/DriveRelativePath.java b/test/java/io/pathNames/win32/DriveRelativePath.java
new file mode 100644
index 0000000..65d7fc7
--- /dev/null
+++ b/test/java/io/pathNames/win32/DriveRelativePath.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright 1997-1998 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/* @test
+   @bug 4070044 4164823
+   @summary Check getCanonicalPath's treatment of drive-relative paths (win32)
+ */
+
+import java.io.*;
+
+
+public class DriveRelativePath {
+
+    static void fail(String s) {
+        throw new RuntimeException(s);
+    }
+
+    public static void main(String[] args) throws IOException {
+
+        if (File.separatorChar != '\\') {
+            /* This test is only valid on win32 systems */
+            return;
+        }
+
+        File f = new File("foo");
+        String c = f.getCanonicalPath();
+        System.err.println(c);
+
+        int di = c.indexOf(':');
+        if (di == -1) fail("No drive in canonical path");
+        String drive = c.substring(0, di + 1);
+        File f2 = new File(drive + "foo");
+        System.err.println(f2);
+        String c2 = f2.getCanonicalPath();
+        System.err.println(c2);
+        if (!c2.equals(c)) fail("Canonical path mismatch: \""
+                                + f2 + "\" maps to \""
+                                + c2 + "\"; it should map to \""
+                                + c + "\"");
+
+    }
+
+}
diff --git a/test/java/io/pathNames/win32/DriveSlash.java b/test/java/io/pathNames/win32/DriveSlash.java
new file mode 100644
index 0000000..7a8c0c5
--- /dev/null
+++ b/test/java/io/pathNames/win32/DriveSlash.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright 1998 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/* @test
+   @bug 4065189
+   @summary Check that win32 pathnames of the form "C:\\"
+            can be listed by the File.list method
+   @author Mark Reinhold
+ */
+
+import java.io.*;
+
+
+public class DriveSlash {
+
+    public static void main(String[] args) throws Exception {
+
+        /* This test is only valid on win32 systems */
+        if (File.separatorChar != '\\') return;
+
+        File f = new File("c:\\");
+        System.err.println(f.getCanonicalPath());
+        String[] fs = f.list();
+        if (fs == null) {
+            throw new Exception("File.list returned null");
+        }
+        for (int i = 0; i < fs.length; i++) {
+            System.err.print(" " + fs[i]);
+        }
+        System.err.println();
+    }
+
+}
diff --git a/test/java/io/pathNames/win32/RenameDelete.java b/test/java/io/pathNames/win32/RenameDelete.java
new file mode 100644
index 0000000..336fcfb
--- /dev/null
+++ b/test/java/io/pathNames/win32/RenameDelete.java
@@ -0,0 +1,80 @@
+/*
+ * Copyright 1998-1999 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug 4042592 4042593
+ * @summary Test operation of rename and delete on win32
+ */
+
+import java.io.*;
+
+/**
+ * This class tests to see if java.io.file rename() method
+ * operates properly with non canonical pathnames
+ * and then tests delete() method with non canonical pathnames
+ */
+
+public class RenameDelete {
+
+    public static void main(String[] args) throws Exception {
+        boolean success = false;
+
+        if (File.separatorChar != '\\') {
+            System.err.println("Not a win32 platform -- test inapplicable");
+            return;
+        }
+
+        //construct a test file in this location
+        File f1 = new File(".");
+        StringBuffer location = new StringBuffer("\\");
+        location.append(f1.getCanonicalPath());
+
+        StringBuffer fromLocation = new StringBuffer(location.toString()+"\\From");
+        StringBuffer toLocation = new StringBuffer(location.toString()+"\\To");
+
+        f1 = new File(fromLocation.toString());
+        File f2 = new File(toLocation.toString());
+
+        if(f1.exists() || f2.exists()) {
+            System.err.println("Directories exist -- test not valid");
+            return;
+        }
+
+        System.err.println("Create:"+f1.mkdir());
+        System.err.println("Exist as directory:"+f1.exists()+" "+f1.isDirectory());
+        success = f1.renameTo(f2);
+        System.err.println("Rename:"+success);
+
+        if (!success)
+            throw new RuntimeException("File method rename did not function");
+
+        success = f2.delete();
+        System.err.println("Delete:"+success);
+
+        if (!success)
+            throw new RuntimeException("File method delete did not function");
+
+    }
+
+}
diff --git a/test/java/io/pathNames/win32/SJIS.java b/test/java/io/pathNames/win32/SJIS.java
new file mode 100644
index 0000000..c91dbb9
--- /dev/null
+++ b/test/java/io/pathNames/win32/SJIS.java
@@ -0,0 +1,82 @@
+/*
+ * Copyright 1998 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/* @test
+   @bug 4039597
+   @summary Check that pathnames containing double-byte characters are not
+            corrupted by win32 path processing
+   @author Mark Reinhold
+*/
+
+import java.io.*;
+
+
+public class SJIS {
+
+    private static void rm(File f) {
+        if (!f.delete()) throw new RuntimeException("Can't delete " + f);
+    }
+
+    private static void touch(File f) throws IOException {
+        OutputStream o = new FileOutputStream(f);
+        o.close();
+    }
+
+    public static void main(String[] args) throws Exception {
+
+        /* This test is only valid on win32 systems
+           that use the SJIS encoding */
+        if (File.separatorChar != '\\') return;
+        String enc = System.getProperty("file.encoding");
+        if ((enc == null) || !enc.equals("SJIS")) return;
+
+        File f = new File("\u30BD");
+        if (f.exists()) rm(f);
+
+        System.err.println(f.getCanonicalPath());
+        touch(f);
+        System.err.println(f.getCanonicalPath());
+
+        rm(f);
+
+        if (!f.mkdir()) {
+            throw new Exception("Can't create directory " + f);
+        }
+        File f2 = new File(f, "\u30BD");
+        System.err.println(f2.getCanonicalPath());
+        touch(f2);
+        String cfn = f2.getCanonicalPath();
+        if (!(new File(cfn)).exists()) {
+            throw new Exception(cfn + " not found");
+        }
+
+        File d = new File(".");
+        String[] fs = d.list();
+        if (fs == null) System.err.println("No files listed");
+        for (int i = 0; i < fs.length; i++) {
+            System.err.println(fs[i]);
+        }
+
+    }
+
+}
diff --git a/test/java/io/pathNames/win32/bug6344646.java b/test/java/io/pathNames/win32/bug6344646.java
new file mode 100644
index 0000000..11a3aa8
--- /dev/null
+++ b/test/java/io/pathNames/win32/bug6344646.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2005 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/* @test
+ * @bug 6344646
+ * @summary tests that Win32FileSystem.hashCode() uses
+ *    locale independent case mapping.
+ */
+
+import java.io.*;
+import java.util.*;
+
+public class bug6344646 {
+    public static void main(String[] s) {
+        /* This test is only valid on win32 systems */
+        if (File.separatorChar != '\\') {
+            return;
+        }
+
+        Locale.setDefault(new Locale("lt"));
+        File f1 = new File("J\u0301");
+        File f2 = new File("j\u0301");
+
+        if (f1.hashCode() != f2.hashCode()) {
+            throw new RuntimeException("File.hashCode() for \"J\u0301\" and \"j\u0301\" should be the same");
+        }
+    }
+}