1 package gov.nasa.jpf.jvm; 20 21 24 public class TestStackTrace { 25 public static void main (String [] args) { 26 TestStackTrace t = new TestStackTrace(); 27 28 if (args.length > 0) { 29 for (int i = 0; i < args.length; i++) { 31 String func = args[i]; 32 33 if ("testGetStackTrace".equals(func)) { 36 t.testGetStackTrace(); 37 } else { 38 throw new IllegalArgumentException ("unknown test function"); 39 } 40 } 41 } else { 42 t.testGetStackTrace(); 44 } 45 } 46 47 public void testGetStackTrace () { 48 getStackTrace_1(); 49 } 50 51 void getStackTrace_1 () { 52 getStackTrace_2(); 53 } 54 55 void getStackTrace_2 () { 56 Throwable t = new Throwable (); 57 StackTraceElement [] s = t.getStackTrace(); 58 59 System.out.println("## " + s.length); 60 61 for (int i = 0; i < s.length; i++) { 62 System.out.println(s[i].getFileName() + ":" + s[i].getLineNumber() + 63 " = " + s[i].getClassName() + "." + 64 s[i].getMethodName()); 65 } 66 } 67 } | Popular Tags |