geronimo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jason Dillon <>
Subject Re: [Error handling] NullPointer or IllegalArgument?
Date Thu, 14 Aug 2003 10:12:28 GMT
NPE should not be an IAE because it does not really fall directly with 
in the domain of arguments.  For example if something returns a 
String[], but String[4] is null when it should not be then it would be 
appropriate to toss a NPE, though it better have a reasonable message, 
else it is not very useful.

I think the original point of this thread was to determine if IAE or 
NPE should be used when an argument to a method was null, I suggest 
using NAE (in geronimo common) for this, which is an IAE.

However in the example above if the array was a method argument, then 
an IAE would be better suited, though I would still suggest NAE and add 
the index which was null for clarity.

BTW, I am not sure why I implemented NAE using an Object for index... 
seems silly now that I think about it, but no time to fix at the moment.


On Thursday, August 14, 2003, at 04:41  PM, Adrian Jackson wrote:

> Confusion between NullPointerException and NullArgumentException, I
> think. :)
> FWIW, it would *not* have been nice if NPE were an IAE - in a lot of
> cases where it's generated, it's not because of an argument. In fact
> it's almost never generated directly as the result of an illegal
> argument.
> Adrian
> -----Original Message-----
> From: Jason Dillon []
> Sent: 14 August 2003 10:31
> To:
> Subject: Re: [Error handling] NullPointer or IllegalArgument?
>> Note on further checking - NPE is not an IAE. They're both
>> RuntimeExceptions but thats about it. Sorry Jason I think you're
>> mistaken - but it would have been nice though.
> Huh?  Was there another Jason on this thread...
> --jason

View raw message