Upstream version 1.3.40
[profile/ivi/swig.git] / Examples / test-suite / java / director_thread_runme.java
1
2 import director_thread.*;
3 import java.lang.reflect.*;
4
5 public class director_thread_runme {
6
7   static {
8     try {
9       System.loadLibrary("director_thread");
10     } catch (UnsatisfiedLinkError e) {
11       System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
12       System.exit(1);
13     }
14   }
15
16   public static void main(String argv[]) {
17     // This test used to hang the process. The solution is to call DetachCurrentThread in ~JNIEnvWrapper, however it causes seg faults in other JNI calls on older JDKs on Solaris. See SWIG_JAVA_NO_DETACH_CURRENT_THREAD in director.swg.
18     director_thread_Derived d = new director_thread_Derived();
19     d.run();
20
21     if (d.getVal() >= 0) {
22         throw new RuntimeException("Failed. Val: " + d.getVal());
23     }
24   }
25 }
26
27 class director_thread_Derived extends Foo {
28   director_thread_Derived() {
29     super();
30   }
31
32   public void do_foo() {
33     setVal(getVal() - 1);
34   }
35 }
36