Blank line exception handling
-
Now I know that even blank lines can throw an exception... I found this pearl in a ServletContextListener class.
public void contextDestroyed(ServletContextEvent sce) { try { } catch (Exception e) { e.printStackTrace(); } }
-
That's because the same class has a method without a name, as in
// called whenever a blank line is encountered
protected void /*nameless*/ () throws Exception {
...
}
-
Probably the application is expected to work in a multithreaded environment.
Thus, an exception may occur in some other part of the program while the blank line is being executed.
And who knows, maybe this exception is so huge as to occupy several threads at once? In fact, it would be safer to write
catch (Exception[ ] theWholeBunch)
or
while( catch( Exception) ) { /*don't panic*/ }
to rescue other threads as well.
-
@IMil said:
Why would the exception subsequently be thrown here, as opposed to, oh I dunno, the part of the program that generated it?Probably the application is expected to work in a multithreaded environment.
Thus, an exception may occur in some other part of the program while the blank line is being executed.
-
@IMil said:
Probably the application is expected to work in a multithreaded environment.
Thus, an exception may occur in some other part of the program while the blank line is being executed.
Either you fail at humour or you fail at Java.
-
@Physics Phil said:
Either you fail at humour or you fail at Java.
I think both you and Belgarion fail at humor.
There is no way he is serious. It is obviously a joke to follow AmmoQ's.
-
@apetrelli said:
Now I know that even blank lines can throw an exception... I found this pearl in a ServletContextListener class.
That's not perl, it's Java!
*crickets*
-
@IMil said:
I know this was a joke, and I don't have a Java compiler handy to check, but I'm pretty sure that this is illegal syntax. It's funnier when it compiles.while( catch( Exception) ) { /*don't panic*/ } [/code]
to rescue other threads as well.
-
100.times { puts "I'll never skip <irony> tags again" }
-
@IMil said:
100.times { puts "I'll never skip <irony> tags again" }
Damn you with your ruby-goodness! Don't infringe on our java cult!
-
Duplication Prevention Bot is back in action!
[url]http://forums.thedailywtf.com/forums/t/7269.aspx[/url]
Enjoy your consequences.
-
-
TRWTF is using Java to catch Whitespace's exceptions.
-
@dlikhten said:
@IMil said:
100.times { puts "I'll never skip <irony> tags again" }
Damn you with your ruby-goodness! Don't infringe on our java cult!
Oh, shut up. The real WTF is that Java was used in the original sample.
In Ruby, the same could have been achieved with metaprogramming in one line or even less!
-
@ammoQ said:
That's because the same class has a method without a name
Too bad VB5 doesn't support invisible methods. It would be like noodles made of optical fibres. Anyhow, I appreciate the 'ridiculous programming constructs' humour in this thread.
-
@IMil said:
In Ruby, the same could have been achieved with metaprogramming in one line or even less!
Oh, come on! You can't just leave it at that. Code samples plz!