Why does the method relativize behave differently on java-8 and java-11?
Path path1 = Paths.get("/a/./b/../image.png");
Path path2 = Paths.get("/a/file.txt");
Path path = path1.relativize(path2);
System.out.println(path);
- java-8 (1.8.0_66 to be exact) prints
../../../../file.txt. JavaDoc. - java-11 (11.0.4 to be exact) prints
../file.txt. JavaDoc.
The JavaDoc description of both versions is equal. I feel the java-11 way looks like a correct behavior to me:
path1:/a/./b/../image.pngnormalizes to/a/b/../image.pngwhich normalizes to/a/image.pngpath2:/a/file.txt- the way to navigate from
/a/image.pngand/a/file.txtis../file.txt
Questions
How is the java-8 way supposed to be calculated? Doesn't it normalize the path? I don't understand how to get the result from head.
Why is there a difference between these two versions that is not documented at all?