commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ola Berg <>
Subject Re: [commons]NPE or IAE?
Date Wed, 21 Aug 2002 21:23:42 GMT
>It has been my experience is that using different exceptions
>to indicate different conditions is preferred (and IMHO these are
>different conditions).  This presents the most 
>flexibility to the

Are they really different? The role of the null object is rather philosphical in nature. I
can see that both views are valid.

IAE is thrown when you break the contract of a real parameter to a method. NPE when you use
a null pointer in an inappropriate way.

Contract states: non-null, non-negative Integer object. Throw IAE for any violation.


Contract states: non-negative Integer object. Throw IAE for any violation. However, since
you must provide an object, it is implicit that null is plain wrong. An illegal use of the
null pointer.

That we should have different exceptions for different conditions, to that we all agree. Else,
we could have used Throwable all the way. My question is whether the conditions really are


0733 - 99 99 17

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

View raw message