Path.startsWith() etc
Alan Bateman
Alan.Bateman at oracle.com
Tue Nov 30 03:58:46 PST 2010
Benedict Elliott Smith wrote:
> Hi,
>
> The UnixPath implementation behaves rather annoyingly when the
> argument is a different type of Path.
>
> Currently a java.nio.file.ProviderMismatchException is thrown, but for
> ease of use it would be preferable (to my mind) to simply return false.
The exception is expected:
"Unless otherwise noted, invoking a method of any class or interface in
this package created by one provider with a parameter that is an object
created by another provider, will throw ProviderMismatchException"
Changing things so that some methods, like startsWith, return false
might be inconsistent. I'm curious how you ran into this as I assume
there must be a bug somewhere. Another thing to mention is that we are
currently missing startsWith(String), endsWith(String), something that
has come up a few times.
>
> Given that the new Path APIs have been designed to make using
> different providers interchangeably and uniformly, does it seem
> sensible to make as many methods as possible "safe" with respect to
> interaction between provider types.
Although the API allows for different providers there is no requirement
that these providers be interoperable (as one provider will not know
anything about the representation of objects associated with other
providers).
-Alan.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/nio-dev/attachments/20101130/17e770d9/attachment.html
More information about the nio-dev
mailing list