Path.compareTo(Path()

Alan Bateman Alan.Bateman at oracle.com
Thu May 26 10:14:39 PDT 2011


Christian Schlichtherle wrote:
>
> The Javadoc says:
>
>  
>
> This method may not be used to compare paths that are associated with 
> different file system providers.
>
>  
>
> Whereas Path.equals(Object) says:
>
>  
>
> If the given object is not a Path, or is a Path associated with a 
> different {@code FileSystem}, then this method returns {@code false}
>
>  
>
> This is inconsistent. If required at all, both methods should 
> discriminate on the FileSystem, not the FileSystemProvider.
>
>  
>
The spec just allows you to compare two Paths that are associated with 
the same provider but different FileSystem instances. They shouldn't be 
equal of course as otherwise it would be inconsistent with equals. I 
think the demo zip provider may have a problem here in that its 
compareTo doesn't take the FileSystem into account.

-Alan.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/nio-discuss/attachments/20110526/7a0b43e0/attachment-0001.html 


More information about the nio-discuss mailing list