Check dynamic inline exceptions (generated after actual code).
[cacao.git] / tests / extest.java
1 public class extest {
2     public static void main(String[] argv) {
3         try {
4             System.out.print("throw Exception: ");
5             sub();
6             System.out.println("failed.");
7         } catch (Exception e) {
8             System.out.println("passed.");
9         }
10
11         try {
12             System.out.print("native Exception: ");
13             System.arraycopy(null, 1, null, 1, 1);
14             System.out.println("failed.");
15         } catch (Exception e) {
16             System.out.println("passed.");
17         }
18
19         try {
20             System.out.print("NullPointerException: ");
21             int[] ia = null;
22             int i = ia.length;
23             System.out.println("failed.");
24         } catch (NullPointerException e) {
25             System.out.println("passed.");
26         }
27
28         try {
29             System.out.print("ArithmeticException: ");
30             int i = 1, j = 0, k = i / j;
31             System.out.println("failed.");
32         } catch (ArithmeticException e) {
33             System.out.println("passed.");
34         }
35
36         try {
37             System.out.print("ArrayIndexOutOfBoundsException: ");
38             int[] ia = new int[1];
39             ia[1] = 1;
40             System.out.println("failed.");
41         } catch (ArrayIndexOutOfBoundsException e) {
42             System.out.println("passed.");
43         }
44
45         try {
46             System.out.print("NegativeArraySizeException: ");
47             int[] ia = new int[-1];
48             System.out.println("failed.");
49         } catch (NegativeArraySizeException e) {
50             System.out.println("passed.");
51         }
52         
53         try {
54             System.out.print("ClassCastException: ");
55             Object o = new Object();
56             Integer i = null;
57             i = (Integer) o;
58             System.out.println("failed.");
59         } catch (ClassCastException e) {
60             System.out.println("passed.");
61         }
62         
63         System.out.println("NullPointerException (without catch): ");
64         String s = null;
65         int i = s.length();
66         System.out.println("failed.");
67     }
68
69     public synchronized static void sub() throws Exception {
70         int a, b, c, d;
71         sub2();
72     }
73
74     public static void sub2() throws Exception {
75         sub3();
76     }
77
78     public synchronized static void sub3() throws Exception {
79         sub4();
80     }
81
82     public static void sub4() throws Exception {
83         throw new Exception();
84     }
85 }