This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
The whole point of the finally block is to have something that will execute no matter what happens. If you don't want it to run, get rid of it. If you have it and you want to avoid it, you're not using it right.
Saurav Rana wrote:Why would someone want to avoid Finally block Execution. But if you just want to know a case when finally block would not be executed , then a System.exit would cause it.
So would unplugging the computer. Or a meteor strike. Or the OS context switching to a different thread or process and never switching back. Or a bug in the JVM. Or a literal bug on the motherboard short-circuiting something.
But all of those--including System.exit()--just come down do "What can stop the JVM from executing any more instructions?" They have nothing to do with finally in particular, and if that's really what the question was about, then it was a rather silly question to start with.