* configure.ac: New switch for disabling -O2 (--disable-optimizations).
[cacao.git] / tests / ReflectEx.java
1 import java.lang.reflect.*;
2
3 public class ReflectEx {
4         public ReflectEx() {
5                 throw new ClassCastException();
6         }
7
8
9
10         public static void main(String [] args) {
11                 try {
12                         ReflectEx o=new ReflectEx();
13                         System.out.println("Test 1 failed (should have gotten exception)");
14                 } catch (Exception e) {
15                         if (! (e instanceof ClassCastException)) {
16                                 System.out.println("Test 1 failed (wrong exception)");
17                         } else {
18                                 System.out.println("Test 1 OK");
19                         }
20                 }
21
22
23                 try {
24                         Class c= Class.forName("ReflectEx");
25                         Constructor con=c.getConstructors()[0];
26
27                         Object o=con.newInstance(new Object[0]);
28                         System.out.println("Test 2 failed (should have gotten exception)");
29                 } catch (Exception e) {
30                         if (! (e instanceof InvocationTargetException)) {
31                                 System.out.println("Test 2 failed (wrong exception)");
32                         } else {
33                                 System.out.println("Test 2 OK");
34                         }
35                 }
36
37
38                 System.out.println("End of test");
39         }
40 }