PageRenderTime 5ms CodeModel.GetById 1ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

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

#
Java | 29 lines | 23 code | 5 blank | 1 comment | 1 complexity | 17fa43cb3704e0d687302aeaf9dbb465 MD5 | raw file
 1
 2import dynamic_cast.*;
 3
 4public class dynamic_cast_runme {
 5  static {
 6    try {
 7        System.loadLibrary("dynamic_cast");
 8    } catch (UnsatisfiedLinkError e) {
 9      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);
10      System.exit(1);
11    }
12  }
13
14  public static void main(String argv[]) 
15  {
16    Foo f = new Foo();
17    Bar b = new Bar();
18
19    Foo x = f.blah();
20    Foo y = b.blah();
21
22    // Note it is possible to downcast y with a Java cast.
23    String a = dynamic_cast.do_test((Bar)y);
24    if (!a.equals("Bar::test")) {
25        System.err.println("Failed!");
26        System.exit(1);
27    }
28  }
29}