Couple of issues in Path class
Rajendra.Gutupalli at Sun.COM
Thu Mar 5 03:39:27 PST 2009
Alan Bateman wrote:
>> 2) This issue looks like bug please let me know if it is.
>> Spec for Path.resolve(String other) says "Converts a given path
>> string to a Path and resolves it against this Path in exactly the
>> manner specified by the Path.resolve(Path other) method. "
>> and in Path.resolve(Path other) says " If other is null then this
>> path is returned."
>> Paht.resolve((Path)null) works as expected but,
>> Path.resolve((String)null) throws NPE.
>> I think as per spec it should not throw NPE.
> The resolve(Path) method allowed to accept null - the rational is that
> this method will commonly be used with the relativize method where the
> relative path between two equal paths is null. If you look at the Copy
> sample code you'll see this in action. If resolve didn't accept null
> then the code would always have to special-case the top-level directory.
Correct Alan, resolve(Path) is working as you mentioned. But the other
overloaded resolve(String) is not allowing me to pass null.
The following code snippet is throwing NPE when tried in Solaris and
Path path = Paths.get("c:/");
Could you please me know what should be the output in the above case?. I
am getting NPE instead of printing path "c:".
More information about the nio-dev