* tests/Makefile.am (EXTRA_DIST): Added $(srcdir) to actually find the
[cacao.git] / tests / stack / exception.java
1 public class exception {
2
3         public exception() {
4         }
5
6         public static void b(int v) throws Exception{
7                 throw new Exception("Exception: value="+v);
8         }
9
10         public static void a() throws Exception {
11                 try {
12                         b(1);
13                 } catch (Exception e) {
14                         System.out.println(e.getMessage());
15                         e.printStackTrace();
16                         System.out.println("Caught in a()");
17                 }
18
19                 b(2);
20         }
21
22         public static void c() throws Exception{
23
24                 try {
25                         d();
26                 } catch (Exception e) {
27                         System.out.println(e.getMessage());
28                         e.printStackTrace();
29                         System.out.println("Caught in c(), rethrowing");
30                         throw e;
31                 }
32
33
34         }
35
36         public static void d() throws Exception{
37                 throw new Exception("Exception: value="+4);
38         }
39
40         public static void e() throws Exception{
41
42                 try {
43                         f();
44                 } catch (Exception e) {
45                         System.out.println(e.getMessage());
46                         e.printStackTrace();
47                         System.out.println("Caught in e(), refilling stacktrace and  rethrowing");
48                         e.fillInStackTrace();
49                         throw e;
50                 }
51
52
53         }
54
55         public static void f() throws Exception{
56                 System.out.println("Entering f");
57                 throw new Exception("Exception: value="+5);
58         }
59
60
61
62         public static void main(String args[]){
63                 try {
64                         a();
65                 }
66                 catch (Exception e) {
67                         System.out.println(e.getMessage());
68                         e.printStackTrace();
69                 }
70                 try {
71                         throw new Exception("3");
72                 }
73                 catch (Exception e) {
74                         System.out.println(e.getMessage());
75                         e.printStackTrace();
76                         
77                 }
78
79                 try {
80                         c();
81                 }
82                 catch (Exception e) {
83                         System.out.println(e.getMessage());
84                         e.printStackTrace();
85                         
86                 }
87
88                 try {
89                         e();
90                 }
91                 catch (Exception e) {
92                         System.out.println(e.getMessage());
93                         e.printStackTrace();
94                         
95                 }
96
97                 try {
98                         throw new ClassCastException();
99                 } catch (Exception e) {
100                         System.out.println(e.getMessage());
101                         e.printStackTrace();
102                 }
103
104                 throw new ClassCastException();
105         }
106 }