diff options
Diffstat (limited to 'Examples/test-suite/java/dynamic_cast_runme.java')
-rw-r--r-- | Examples/test-suite/java/dynamic_cast_runme.java | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/Examples/test-suite/java/dynamic_cast_runme.java b/Examples/test-suite/java/dynamic_cast_runme.java new file mode 100644 index 000000000..be1f97b35 --- /dev/null +++ b/Examples/test-suite/java/dynamic_cast_runme.java @@ -0,0 +1,29 @@ + +import dynamic_cast.*; + +public class dynamic_cast_runme { + static { + try { + System.loadLibrary("dynamic_cast"); + } catch (UnsatisfiedLinkError e) { + 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); + System.exit(1); + } + } + + public static void main(String argv[]) + { + Foo f = new Foo(); + Bar b = new Bar(); + + Foo x = f.blah(); + Foo y = b.blah(); + + // Note it is possible to downcast y with a Java cast. + String a = dynamic_cast.do_test((Bar)y); + if (!a.equals("Bar::test")) { + System.err.println("Failed!"); + System.exit(1); + } + } +} |