On Sun, Nov 22, 2009 at 4:36 PM, Stephen Colebourne
<scolebou...@btopenworld.com> wrote:
> Henri Yandell wrote:
>>
>> On Thu, Nov 19, 2009 at 9:24 AM, Paul Benedict <pbened...@apache.org>
>> wrote:
>>>
>>> On Thu, Nov 19, 2009 at 1:39 AM, Henri Yandell <flame...@gmail.com>
>>> wrote:
>>>
>>>> Your argument being that the JDK and others do NPE when null? i.e. NPE
>>>> = IAE(null)?
>>>
>>> Yes. Some things to note:
>>> * The JDK does this as their pattern
>>> * JDK 7 definitely encodes this patter in their new Object.notNull()
>>> method.
>>> * Google Collections -- being a JDK wannabe addition -- does this
>>> * Josuha Bloch's "Effective Java" (two editions) has codified this
>>> expectation into the minds of developers.
>>
>> +1 to NPE.
>
> While I know this is the modern advice, there will be other places where any
> NPE is a bug, and thus Validate should throw IAE.

Other places in the JDK, or in some other library, or that there are
places that choose the non-'modern advice'?

> There are no pretty solutions
> - two classes ValidateNPE and ValidateIAE?

I don't think Validate is that important a class to warrant two impls.

> - some kind of static flag?

Seems brittle. Though a -D property could be doable, that implies
singleton-for-jvm better than just a static flag where people will
want to play funny games with classloaders. Still feels bad though as
wouldn't it mean the API throwing Exception?

> - picking one, and offending the others?

+1 :) I've got better things to do in life than burn time supporting
alternative opinions. Unless the JDK is wrong, JDK wins imo.

Hen

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
For additional commands, e-mail: dev-h...@commons.apache.org

Reply via email to