Re: Introspect whether setCharacterEncoding is present..

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

> As mentioned, I do this all the time!! Or do you mean that the -extreme-
> speed-difference from log4j's showing location info or not is only due to
> the string-parsing, not the actual stack-capture?

The stack-capture costs almost nothing. VMs shouldn't have to alloc
it, the frames are already there!


> Yeah, that's "a couple of Kbs" allocated on the heap for each and every
> Exception you throw (and also the String message, if you include that).
> Coders used to make object-pools for smaller Objects than that! (However,
> that'll no longer be an speed-increase, though).

No, you only generate the stack trace bloat when you serialize
(communicate in some way, say IO) the stack trace. Other than that you
don't need to. You've just got a captured stack frame with all it's
parent stack frames. You had these anyway, you don't have to alloc
them.



> | 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.
> 
> You may, as I've mentioned, use "booleans and ifs", right? It'll look like
> hell, but you won't be using Exceptions.
> 
> But then again: you might be right: maybe Sun have taken folks like
> yourself into account with the current JVMs, and made Exception-throwing
> and catching really quick now.. So that all the articles and posts out
> there that states that "don't use Exceptions" -no longer- are correct?
>   (But they certainly were correct at some point!)

I don't get this. "All" the articles is disengenuous. In that google
search I found quite a few responses who were *not* "anti-exceptions as
control flow" (perhaps not as many as the anti's but maybe that's
because of the java style advice, which is new on me I have to admit).

I've always used exceptions like this when I've had cause because
they've always been fast. I've never experienced slowness. I don't
know how the Sun VM is implemented but I do know how GCJ and Kaffe do
it... and their strategies for exceptions are not the cause of slow
code.


Nic


------------------------ 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/