title: How to get full stack of StackOverflowError
body: <p><strong>When observing a StackOverflowError how to retrieve the full call stack?</strong></p>
  
  <p>Consider this simple example:</p>
  
  <pre><code>public class Overflow {
  
      public Overflow() {
          new Overflow();
      }
      public static void a() {
          new Overflow();
      }
      public static void main(String[] argv) {
          a();
      }
  }
  </code></pre>
  
  <p>Now the error reported is:</p>
  
  <pre><code>Exception in thread "main" java.lang.StackOverflowError
      at Overflow.&lt;init&gt;(Overflow.java:11)
      [last line repeated many times]
  </code></pre>
  
  <p>But I can't see the <code>main</code> and <code>a</code> method in the stack trace. My guess is this is because of overflow, the newest entry on the stack replaces the oldest one (?).</p>
  
  <p>Now, how to get the <code>a</code> and <code>main</code> stack entries in the output? </p>
  
  <p>The background is I get the a StackOverflowError (but that's not an infinite recursion, because it doesn't happen when increasing stack size) and it's hard to spot the problem in the code. I only get the multiple lines from <code>java.util.regex.Pattern</code> but not the information what code called that. The application is too complicated to set a breakpoint on each call to <code>Pattern</code>s.</p>