Re: Introspect whether setCharacterEncoding is present..
Endre Stølsvik <[email protected]> Tue, 12 Oct 2004 17:29:10 +0200 (CEST)
| Newsgroups | gmane.comp.java.advanced-servlets |
|---|---|
| Message-ID | <Pine.LNX.4.44.0410121717500.26253-100000@excalibur.intra.coretrek.com> |
On 12 Oct 2004, Nic Ferrier wrote: | | =?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). 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? | 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. 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). | | 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). I get that you don't actually need to parse the entire stack on Exception creation, but leave that untill you need the frame.. And also, from 1.5 (or whatever), I think that Sun's JIT-thingy is doing some smart Exception-handling optimizatin, where a often-thrown Exception's stack-trace is just dropped, or at least cropped, or something like that. So that if you use Exceptions as you obviously do, then the JIT will stop allocating space for the stacktrace after some iterations. Or something like that. | | | > 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. Well, slightly less silly than -stating- that my opinions and thinking are silly, maybe?! ;) | 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!) Endre ------------------------ Yahoo! Groups Sponsor --------------------~--> $9.95 domain names from Yahoo!. Register anything. http://us.click.yahoo.com/J8kdrA/y20IAA/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/