[jdom-interest] Re: NoSuch*Exception
jhunter at collab.net
Wed Jun 28 11:05:28 PDT 2000
Sirtaj Singh Kang wrote:
> On Wed, Jun 28, 2000 at 07:54:55AM -0400, Thomas M. Sasala wrote:
> > Sirtaj Singh Kang wrote:
> > If null is returned and it is not checked for,
> > then you will get a null pointer exception. There's your
> > error ;)
> Not until it is dereferenced. Consider that it might be put into
> a database field or a collection. Then the effect of the error is
> discovered two or three steps away from where it is actually located,
> which is great if you enjoy debugging.
> (Please don't forget that this is probably by far the most common source
> of runtime errors in programming languages that don't have exceptions.)
In fact right now I'm trying to track down an NPE that a customer of one
of my products is getting. It's especially bad because NPE's don't tell
you what variable was null, the stack traces don't always include line
numbers, and so I have to hand hold the customer.
I think Sirtaj is making excellent points. I also saw someone post
about the convenience of getChild("foo").getContent() -- something
that's really only possible if we throw exceptions. Saying you'll catch
an NPE here isn't compelling.
More information about the jdom-interest