I met the following problem in a Java exam, why following recursively calling a function can run forever even though StackOverflowError?
public class Solution {
static int i = 0;
public static void f(){
System.out.println(i++);
try {
f();
} catch (StackOverflowError e) {
System.out.println(e);
f();
}
}
public static void main(String[] args) {
f();
}
}
I cannot understand why JVM can still run when I've exhausted all call stack memory? Is there any reference, like JVM specification or JVM source code, can explain above phenomenon?