class TestStack { public static int count=55; public static void main(String... args) { try { new TestStack().method(); } catch(Exception e) { StackTraceElement[] traceArray = e.getStackTrace(); System.out.println("stack trace depth="+traceArray.length); } } public void method() throws Exception{ count++; if(count>65535) { throw new Exception("aha!"); } method(); } }