< prev index next >

src/jdk.jartool/share/classes/sun/tools/jar/Main.java

Print this page
rev 51097 : 8207395: jar has issues with UNC-path arguments for the jar -C parameter [windows]

@@ -631,14 +631,18 @@
                         /* change the directory */
                         String dir = args[++i];
                         dir = (dir.endsWith(File.separator) ?
                                dir : (dir + File.separator));
                         dir = dir.replace(File.separatorChar, '/');
+
+                        String unc = (dir.startsWith("//") && (File.separatorChar == '\\')) ? "/" : "";
                         while (dir.indexOf("//") > -1) {
                             dir = dir.replace("//", "/");
                         }
-                        pathsMap.get(version).add(dir.replace(File.separatorChar, '/'));
+                        // Restore the second leading '/' needed for the Windows UNC path.
+                        dir = unc + dir;
+                        pathsMap.get(version).add(dir);
                         nameBuf[k++] = dir + args[++i];
                     } else if (args[i].startsWith("--release")) {
                         int v = BASE_VERSION;
                         try {
                             v = Integer.valueOf(args[++i]);
< prev index next >