Defined SUPPORT_CONST_ASTORE and SUPPORT_ONLY_ZERO_ASTORE.
[cacao.git] / tests / kaffe / ProcessClassLockTest.java
1 /**
2  * a test to ensure we do upcalls to static initializers properly.
3  *
4  * @author Godmar Back <gback@cs.utah.edu>
5  */
6 class Base {
7     static {
8         try {
9             Thread.sleep(5000);
10         } catch (Exception e) {
11             System.out.println(e);
12         }
13     }
14 }
15
16 class Sub extends Base {
17 }
18
19 public class ProcessClassLockTest
20 {
21     public static void main(String av[]) throws Exception {
22         // a watchdog thread that kills us off after 2.5 sec
23         new Thread() {
24             public void run() {
25                 try {
26                     Thread.sleep(2500);
27                     System.out.println("sorry, you timed out");
28                     System.exit(-1);
29                 } catch (Exception e) {
30                     System.out.println(e);
31                 }
32             }
33         }.start();
34
35         // a thread that will load Sub and Base
36         new Thread() {
37             public void run() {
38                 try {
39                     Class.forName("Sub");
40                 } catch (Throwable t) {
41                     System.out.println(t);
42                 }
43             }
44         }.start();
45
46         // get thread 2 going
47         Thread.sleep(1000);
48
49         /* this thread should be unaffected by the fact that thread 2
50          * sleeps in the static initializer of Base
51          */
52         new Thread() {
53             public void run() {
54                 try {
55                     Class.forName("this_class_does_not_exist");
56                 } catch (Throwable t) {
57                     System.out.println(t);
58                 }
59                 System.exit(0);
60             }
61         }.start();
62     }
63 }
64
65 /* Expected Output:
66 java.lang.ClassNotFoundException: this_class_does_not_exist
67 */