Paul Benedict pbenedict at apache.org
Thu Jan 13 22:09:57 UTC 2011

Maybe you have a nonNull() that throws NPE, and a nonNullSafe() ?

On Thu, Jan 13, 2011 at 3:12 PM, Tom Hawtin <tom.hawtin at oracle.com> wrote:

> On 13/01/2011 20:06, Brian Goetz wrote:
>  Most of the other methods in this class are of the form "do the right
>> thing if the object is null (or an array)", but this one is "throw an
>> exception if the object is null." The intent is clear -- it is for
>> simplifying fail-fast behavior by checking for nullity early -- but the
>> name is wrong. This is bad for two reasons: (a) it is confusing and (b)
>> it forecloses on using the name nonNull() for what most people expect it
>> to do -- which is provide a reasonable default.
> I think this is completely the wrong way around. On encountering a null the
> right thing is to throw an NPE. Don't make Sir C.A.R. Hoare's billion-dollar
> mistake worse.
> Perhaps the carpet-sweeping methods should be renamed, or put into an
> appropriately named class.
> Tom
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/core-libs-dev/attachments/20110113/5cfae1b0/attachment.html>

More information about the core-libs-dev mailing list