PageRenderTime 45ms CodeModel.GetById 37ms app.highlight 4ms RepoModel.GetById 2ms app.codeStats 0ms

/trunk/Examples/test-suite/java/director_thread_runme.java

#
Java | 36 lines | 27 code | 8 blank | 1 comment | 1 complexity | 6245c7c2c86ad28e87bceaca017b14ac MD5 | raw file
 1
 2import director_thread.*;
 3import java.lang.reflect.*;
 4
 5public 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
27class 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