Better function header dump
[official-gcc.git] / libjava / testsuite / libjava.lang / stacktrace.java
blobf8823a15f07d216d094c9509884a9fc36e3d4133
1 /* This test should test the stacktrace functionality.
2 We only print ClassName and MethName since the other information
3 like FileName and LineNumber are not consistent while building
4 native or interpreted and we want to test the output inside the dejagnu
5 test environment.
6 Also, we have to make the methods public since they might be optimized away
7 with inline's and then the -O3/-O2 execution might fail.
8 */
9 public class stacktrace {
10 public static void main(String args[]) {
11 try {
12 new stacktrace().a();
13 } catch (TopException e) {
17 public void a() throws TopException {
18 try {
19 b();
20 } catch (MiddleException e) {
21 throw new TopException(e);
25 public void b() throws MiddleException {
26 c();
29 public void c() throws MiddleException {
30 try {
31 d();
32 } catch (BottomException e) {
33 throw new MiddleException(e);
37 public void d() throws BottomException {
38 e();
41 public void e() throws BottomException {
42 throw new BottomException();
46 class TopException extends Exception {
47 TopException(Throwable cause) {
48 super(cause);
52 class MiddleException extends Exception {
53 MiddleException(Throwable cause) {
54 super(cause);
58 class BottomException extends Exception {
59 BottomException() {
60 StackTraceElement stack[] = this.getStackTrace();
61 for (int i = 0; i < stack.length; i++) {
62 String className = stack[i].getClassName();
63 String methodName = stack[i].getMethodName();
64 System.out.println(className + "." + methodName);