operation system is not mentioned in the question, although the paths look like windows paths.
So we have to think it does not matter where code is running.
So if you use paths with c:\\ and try p.relativize(p.resolve(q)).equals(q) on windows, it may not print true.
- of course and everywhere, since according javadoc for this expression to be fulfilled the path q should not have a root component and both paths should be normalized.
it is not our case.
We have two absolute paths and one of them is not normalized.
Moreover, we can just remove prefix "c:\\" from the example of code above to make them not absolute. What do we get? The same answer but without prefix "c:\\" (tested on windows)
So my questions remain in force.
1) why p.resolve(p.relativize(q)).normilize() != q.normilize() ? Note, it is not the same as expression above.
I think it is an equivalent of what javadoc says:
Code: Select all
Relativization is the inverse of {@link #resolve(Path) resolution}.
- it is the second line of method description.
Or I am not right and the expression and statement are not equivalent? Then how I can test this statement ('relativization is the inverse of resolution') ?
or maybe it is not true for two absolute windows-style paths where one of them has '..' inside (i.e. maybe it is mythical JDK-6925169)?
2) or maybe if it is not true since
Where both paths have a root component then it is implementation dependent if a relative path can be constructed
? If so, how we can calculate the true answer at all? It is unpredictable on windows.
What about linux? In the discussion above said that there is also problem here - instead '/personal/index.html' we get '/index.html'. I.e. almost the same answer,