-
Bug
-
Resolution: Fixed
-
P3
-
9
-
b124
-
windows
-
Verified
The result should be "..". In fact, the current return value is quite strange that its getName(0) is also ..\. Seems like \ is not treated as a path separator.
The problem is inside relativize() of WindowsPath.java:
416 // append remaining names in child
417 for (int j=i; j<cn; j++) {
418 result.append(other.getName(j).toString());
419 result.append("\\");
420 }
Here, when other.getName(j).toString() is empty, a backslash should not be added.
Another similar issue. Paths.get("D:").toAbsolutePath() becomes D:\xyz\ instead of D:\xyz. The WindowsPath::getAbsolutePath() method leaves a trailing slash when remaining is empty below.
252 result = defaultDirectory + "\\" + remaining;
The problem is inside relativize() of WindowsPath.java:
416 // append remaining names in child
417 for (int j=i; j<cn; j++) {
418 result.append(other.getName(j).toString());
419 result.append("\\");
420 }
Here, when other.getName(j).toString() is empty, a backslash should not be added.
Another similar issue. Paths.get("D:").toAbsolutePath() becomes D:\xyz\ instead of D:\xyz. The WindowsPath::getAbsolutePath() method leaves a trailing slash when remaining is empty below.
252 result = defaultDirectory + "\\" + remaining;
- relates to
-
JDK-8066943 (fs) Path.relativize() gives incorrect result for ".."
- Resolved