title: Why is it possible to recover from a StackOverflowError?
body: <p>I'm surprised at how it is possible to continue execution even after a <a href="https://stackoverflow.com/questions/214741/what-is-a-stackoverflowerror"><code>StackOverflowError</code></a> has occurred in Java.</p>
  
  <p>I know that <code>StackOverflowError</code> is a sublass of the class Error.
  The class Error is decumented as "a subclass of Throwable that indicates serious problems that a reasonable application should not try to catch."</p>
  
  <p>This sounds more like a recommendation than a rule, subtending that catching a Error like a StackOverflowError is in fact permitted and it's up to the programmer's reasonability not to do so. And see, I tested this code and it terminates normally.</p>
  
  <pre><code>public class Test
  {
      public static void main(String[] args)
      {
          try {
              foo();
          } catch (StackOverflowError e) {
              bar();
          }
          System.out.println("normal termination");
      }
  
      private static void foo() {
          System.out.println("foo");
          foo();
      }
  
      private static void bar() {
          System.out.println("bar");
      }
  }
  </code></pre>
  
  <p>How can this be? I think by the time the StackOverflowError is thrown, the stack should be so full that there is no room for calling another function. Is the error handling block running in a different stack, or what is going on here?</p>