Why does Path.getParent() return null?

Paulo Levi i30817 at gmail.com
Thu Feb 6 10:12:13 PST 2014


I'm curious about the reason for not having a special empty path for the
case where the parent doesn't exist instead of returning null.

There is quite a bit of code on my experience that has to check for null,
when they only call get parent even once, while if it returned a special
null empy-space object they would never have to. Even Path.get("",
"somedir") ignores the whitespace so it could use that has a
representation. Or is the problem that that is already taken for current
directory in the path implementation (although i've found that it doesn't
have that effect on the get ).

Also, i'd like to know if that method will be annotated with a
@CheckForNull or similar on the jdk.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/nio-discuss/attachments/20140206/a5f5c56a/attachment.html 


More information about the nio-discuss mailing list