/trunk/Examples/test-suite/java/dynamic_cast_runme.java
Java | 29 lines | 23 code | 5 blank | 1 comment | 1 complexity | 17fa43cb3704e0d687302aeaf9dbb465 MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
- 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);
- }
- }
- }