That gives a different result. Original: "///" -> “/"
replaceAll: "///" -> “//" > On Jul 18, 2018, at 7:18 AM, Baesken, Matthias <matthias.baes...@sap.com> > wrote: > > Hi Götz, thanks for the input ! > Should we maybe use > > dir.replaceAll > > and not the while loop ? > >> while (dir.indexOf("//") > -1) { >> dir = dir.replace("//", "/"); >> } > > Best regards, Matthias > > >> -----Original Message----- >> From: Lindenmaier, Goetz >> Sent: Mittwoch, 18. Juli 2018 11:32 >> To: Baesken, Matthias <matthias.baes...@sap.com>; core-libs- >> d...@openjdk.java.net >> Subject: RE: RFR : 8207395: jar has issues with UNC-path arguments for the >> jar -C parameter [windows] >> >> Hi Matthias, >> >> thanks for doing this fix. >> >> I think this can be noted down a bit better, avoiding duplicating the loop. >> Also, please remove the redundant dir.replace(File.separatorChar, '/'). >> >> 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]; >> >> Best regards, >> Goetz. >> >>> -----Original Message----- >>> From: core-libs-dev [mailto:core-libs-dev-boun...@openjdk.java.net] On >>> Behalf Of Baesken, Matthias >>> Sent: Dienstag, 17. Juli 2018 13:15 >>> To: core-libs-dev@openjdk.java.net >>> Subject: [CAUTION] RFR : 8207395: jar has issues with UNC-path arguments >>> for the jar -C parameter [windows] >>> >>> Please review this small fix for allowing windows UNC paths in the jar >>> -C >>> parameter. >>> Currently passing a UNC path to a directory with -C <dir> fails : >>> >>> c:\testdir>c:\tools\jdk10\bin\jar.exe test.jar -C \\MYMACHINE\subdir >>> README.txt >>> Illegal option: s >>> Try `jar --help' for more information. >>> >>> With the patch it works . >>> >>> webrev >>> >>> http://cr.openjdk.java.net/~mbaesken/webrevs/8207395/ >>> >>> bug >>> >>> https://bugs.openjdk.java.net/browse/JDK-8207395 >>> >>> >>> >>> >>> Thanks, Matthias >