// This class shows what happens when you overflow the stack. // The "try" block prevents the system from generating a run-time // stack trace when the program aborts. // // To make the crash happen sooner, add some large local variables to // the recurse method, to make each stack frame (activation record) // larger. // // Written 2004 by Wayne Pollock, Tampa Florida USA. class StackGoBoom { public static void main ( String [] args ) { try { recurse( 1 ); } catch ( Throwable t ) { System.out.println( t ); } } static void recurse ( int level ) { System.out.println( level ); recurse( level + 1 ); } }