[jdom-interest] NoSuch*Exceptions in JDOM

Steve Odendahl steve.odendahl at central.sun.com
Mon Jul 10 10:13:59 PDT 2000


I'd also add the Mark Roulo article in JavaWorld

http://www.javaworld.com/javaworld/jw-09-1998/jw-09-speed-2.html

"The cost of throwing an exception is higher than the cost of 
setting up a try/catch block. Since exception handling shouldn't 
be done on a speed-critical path, this doesn't bother me and I 
haven't benchmarked it."

(Interestingly, this article shows that under the JITs of those
days (and probably still), the cost of setting up a try-catch 
block is nearly zero.  So ... "using exceptions in Java programs 
can actually speed up the program when compared to an equivalent 
program using status codes.")

I'm also using the same technique as Andre, except the two methods
are named "getChild" (returns null) and "getRequiredChild" (throws
exception), and I believe it helps make my code more understandable.  

	Steve Odendahl
	(Not speaking for Sun Microsystems, Inc.)

On Mon, Jul 10, 2000 at 06:28:34PM +0200 or thereabouts, Andre Van Delft wrote:
> 
> Some information is in
> http://java.sun.com/docs/books/vmspec/2nd-edition/html/Overview.doc.html#15494
> http://www.javaworld.com/javaworld/jw-01-1997/jw-01-hood.html
> 
> Throwing and catching a new exception involves at least:
> - creating the exception
> - looking up the exception in a catch table
> This all performes badly as compared to returning a value.
> 
> It seems that JavaWorld would vote for a getChild that
> does not throw exceptions. See:
> 
> http://www.javaworld.com/javaworld/javaqa/1999-06/04-exceptions.html
> http://www.javaworld.com/javaworld/jw-07-1998/jw-07-techniques-2.html
> 
> Quote:
> >The most important point to take away from this article is that
> >exceptions are there for abnormal conditions and
> >shouldn't be used to report conditions that can be
> >reasonably expected as part of the everyday functioning
> >of a method.
> 
> 
> 
> _______________________________________________
> To control your jdom-interest membership:
> http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhost.com



More information about the jdom-interest mailing list