Path's .relativize documentation is wrong on a crucial point

Alan Bateman Alan.Bateman at oracle.com
Sun Dec 13 07:00:54 UTC 2015



On 12/12/2015 23:03, Francis Galiegue wrote:
> Let us have a FileSystemProvider which provides FileSystems with
> Unix-like Paths.
>
> Let us have two FileSystems from that same provider fs1 and fs2.
>
> Let us have p issued from FileSystem fs1 which is "a".
>
> Let us have q issued from FileSystem fs2 which is "b".
>
> Let us call r the result of p.resolve(q). Since this is a Unix-like
> filesystem, none of p and q have root components (that would be /),
> and the resulting path r would be "a/b", on filesystem fs1.
>
> Now, let us do:
>
> p.relativize(r)
>
> Both p (which is "a") and r (which is "a/b") are on fs1; the result is
> "b", which is on... fs1.
>
> Which contradicts the equality of the Path's .relativize() which says that:
>
> ----
>
> For any two normalized paths p and q, where q does not have a root component,
>
>      p.relativize(p.resolve(q)).equals(q)
> ----
>
>
Yes, there is a spec issue here as this should make it clear that and 
paths p and q are the same FileSystem. I will create a bug for this, 
assuming we don't have one already.

-Alan


More information about the nio-dev mailing list