This week's giveaway is in the EJB and other Java EE Technologies forum. We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line! See this thread for details.
Whats the point of rethrowing an exception from a catch block when it cant be handled by other catch blocks. And if the exception rebounds back to the calling method, isnt a JVM shutdown then inevitable?
If the exception rebounds back to the calling method, it isn't inevitable that you're going to have a JVM shutdown - there are times when I'm programming that the "proper" response is to kick the message back a step to let the calling method deal with the matter. For instance, when I'm writing a utility class for large portions of an app, I'm going to want to handle any issues that arrise in different ways depending on what's happening at the moment when it was called, rather than having a single standard method. Perhaps in one spot it's appropriate to stop processing, while at others it's more appropriate to simply flag a warning and continue.
As for the point of rethrowing the exception, again, sometimes there's other things you're going to want to do with the thrown exception, after initially dealing with it. (At my office, for instance, we sometimes wrap our exceptions in another exception as we throw back to the calling method, to have a standard message appear for our users, while allowing us to see what was going on.)
Theodore Jonathan Casser
SCJP/SCSNI/SCBCD/SCWCD/SCDJWS/SCMAD/SCEA/MCTS/MCPD... and so many more letters than you can shake a stick at!