Why isn't the code trying to catch the StackOverflowError being triggered?

This question extends from this stackoverflow question .

If I add a catch block, why do the catch block codes never run?

public static void foo() {
    try {
        foo();
    } catch(StackOverflowError e) {       
       System.exit(1); // or System.err.println("ouch!"); whatever
    } finally {
        foo();
    }
}

      

I am referring to JLS Chapter 11.1.3 - Asynchronous exceptions - is this the reason why the catch blocking reason has no chance to run?

+3


source to share





All Articles