OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libjava/] [testsuite/] [libjava.lang/] [stacktrace.java] - Blame information for rev 765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 765 jeremybenn
/* 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) {
14
    }
15
  }
16
 
17
  public void a() throws TopException {
18
    try {
19
      b();
20
    } catch (MiddleException e) {
21
      throw new TopException(e);
22
    }
23
  }
24
 
25
  public void b() throws MiddleException {
26
    c();
27
  }
28
 
29
  public void c() throws MiddleException {
30
    try {
31
      d();
32
    } catch (BottomException e) {
33
      throw new MiddleException(e);
34
    }
35
  }
36
 
37
  public void d() throws BottomException {
38
    e();
39
  }
40
 
41
  public void e() throws BottomException {
42
    throw new BottomException();
43
  }
44
}
45
 
46
class TopException extends Exception {
47
  TopException(Throwable cause) {
48
    super(cause);
49
  }
50
}
51
 
52
class MiddleException extends Exception {
53
  MiddleException(Throwable cause) {
54
    super(cause);
55
  }
56
}
57
 
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);
65
    }
66
  }
67
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.