commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stephen Colebourne" <>
Subject Re: [commons]NPE or IAE?
Date Wed, 21 Aug 2002 22:23:00 GMT
I raised this issue a while back.

My understanding is that Sun uses NPE for nulls because of performance
reasons based in JDK 1.0. A NPE is auto checked, whereas an IAE would be
specifically coded, hence slower. Now of course that argument is ridiculous.

My preferred solution is a NullArgumentException that subclasses IAE.
However, really that would need to be a Sun class applied to the whole
library. So, collections at least must follow the NPE route.

BTW, where I work the rule is that the product should never throw NPEs. If
it does, its a bug. IAEs are thrown if a null is passed into a method that
doesn't accept it. I don't think this is uncommon practice.

Having said all that, if commons is eventually to create a core.jar file,
then really the exception handling should be consistent across it. Since
[collections] is fixed on NPE, I reckon [io], [lang] and [pattern] must
follow suit.


From: "Ola Berg" <>
> >Those callers who believe they are separate conditions can handle them
> >separately.
> True. But since they are runtime exceptions, they can be avoided by the
caller anyway. One can argue that if they ever occur, it is a bug in their
programs, so they should not have any automatic handling of the condition
anyway. They should read the message: \"This is illegal, it shouldn\'t be
null.\", and do any assertions on their part.
> >Those who believe they are the same can handle them the
> >same.
> How do they handle them the same?
> BTW, PredicateUtils uses IAE even for nulls.
> /O
> --------------------
> 0733 - 99 99 17
> --
> To unsubscribe, e-mail:
> For additional commands, e-mail:

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message