Re: Introspect whether setCharacterEncoding is present..

Nic Ferrier <[email protected]> 12 Oct 2004 16:18:14 +0100
Newsgroups gmane.comp.java.advanced-servlets
Message-ID <[email protected]>
=?iso-8859-1?Q?Endre_St=F8lsvik?= <[email protected]> writes:

> An Exception is "heavy to make" - its a) an Object, b) a big Object (!),
> c) have this awfully long (in Tomcat, at least!) StackTrace to be
> generated and filled in (I mean, its a ton of strings, numbers, whatevers,
> that need to be fetched off of the stack, and loaded into some internal
> representation..)
> 
> One should, in my opinion, definately avoid throwing Exceptions in any
> "critical paths" of a system. This also goes for 'return codes': the
> normal "exit values" should be integers, Strings, whatevers, and -not-
> Exceptions..

*Go and test it* on different VMs (or look the tests up in
Google). Exceptions don't have to be heavier than any other object and
I think you'll be surprised at how fast exception throwing can be
(it's quite slow on the MS VM, but who cares about that these days?)


Stack traces are not complex. Even the most ridiculous stack traces
I've seen (from WebSphere) are only just bigger than 400 lines. At
most I guess it's a couple of Kb of data.

And, from a VMs point of view, an exception is just the captured
stack. Capturing the stack is very quick and easy (and quite fun).


> Well, they can be used for many nice things, but I'd also say that
> they should be avoided in the critical paths of any program.

This is silly Endre. What if the critical path of your program is
where you need a non-local exit? How is a yacc like tool to be built
in Java without non-local exits? Clearly non-local exits are going to
be on the critical path for such a program.



-- 
Nic Ferrier
http://www.tapsellferrier.co.uk


------------------------ Yahoo! Groups Sponsor --------------------~--> 
Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar.
Now with Pop-Up Blocker. Get it for free!
http://us.click.yahoo.com/L5YrjA/eSIIAA/yQLSAA/saFolB/TM
--------------------------------------------------------------------~-> 

Before posting a question, try to find your answer here: 
<http://www.egroups.com/links/advanced-servlets>
Announcements should go to: [email protected]
To Post a message, send it to: [email protected]
To Unsubscribe, send a blank message to: [email protected] 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/advanced-servlets/

<*> To unsubscribe from this group, send an email to:
    [email protected]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/