< 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,13 +631,22 @@
                         /* change the directory */
                         String dir = args[++i];
                         dir = (dir.endsWith(File.separator) ?
                                dir : (dir + File.separator));
                         dir = dir.replace(File.separatorChar, '/');
+
+                        if (dir.startsWith("//") && (File.separatorChar == '\\') ) {
                         while (dir.indexOf("//") > -1) {
                             dir = dir.replace("//", "/");
                         }
+                            // restore the leading / to fix the Win UNC path
+                            dir = "/" + dir;
+                        } else {
+                            while (dir.indexOf("//") > -1) {
+                                dir = dir.replace("//", "/");
+                            }
+                        }
                         pathsMap.get(version).add(dir.replace(File.separatorChar, '/'));
                         nameBuf[k++] = dir + args[++i];
                     } else if (args[i].startsWith("--release")) {
                         int v = BASE_VERSION;
                         try {
< prev index next >