8140449: (fs) Paths.get("x").relativize("") return ..\ on Windows

Wang Weijun weijun.wang at oracle.com
Fri Jun 17 15:02:13 UTC 2016


 246             if (remaining.length() == 0) {
 247                 return defaultDirectory;

What is defaultDirectory ends with \ above? Shall we remove it?

 248             } else if (defaultDirectory.endsWith("\\")) {
 249                  return defaultDirectory + remaining;
 250             } else {
 251                 return defaultDirectory + "\\" + remaining;
 252             }

--Max

> On Jun 17, 2016, at 5:59 PM, Alan Bateman <Alan.Bateman at oracle.com> wrote:
> 
> 
> This issue relates to two corner cases on Windows that result in a leading slash. One is Paths.get("C:").toAbsolutePath(), the other is Paths.get("x").relativize(""). The changes are simple and I've expanded the test coverage to cover more cases. There is further work requires on relativize but that is for another issue. The proposed changes are here:
> 
> http://cr.openjdk.java.net/~alanb/8140449/webrev/
> 
> Thanks,
> 
> Alan
> 



More information about the nio-dev mailing list