I have a thread in which I catch all the errors in a large, comprehensive catch block. I do this so that I can report any errors, not just expected, in my application. My runnable looks like this:
public final void run()
{
try
{
System.out.println("Do things");
doUnsafeThings();
}
catch (Throwable t)
{
System.out.println("Catch");
recover();
}
finally
{
System.out.println("Finally");
}
}
I would expect NPE to catch the Throwable catch block. Instead, the conclusion in [2] is not printed, and not one of them [3]. The conclusion is deduced in [1].
What I do on the console is this:
Uncaught exception java/lang/NullPointerException.
What's going on here?
For court records, I use J2ME, and this works in the Sun WTK v2.5.2 emulator.
I am tempted to put it on a fine-tuning of the JVM implementation, but I cannot help but feel that I just missed something.
To clarify for the avoidance of doubt (as the sample code is obviously modified from my production code)
- try/catch/finally.
- System.out.println. , .