missing run test

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@5091 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2003-09-08 22:06:28 +00:00
commit 1f02d8409a

View file

@ -0,0 +1,61 @@
public class main
{
static {
try {
System.loadLibrary("example");
} 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[] args)
{
System.out.println("Adding and calling a normal C++ callback");
System.out.println("----------------------------------------");
Caller caller = new Caller();
Callback callback = new Callback();
caller.setCallback(callback);
caller.call();
caller.delCallback();
// Unlike Python, Java does not automatically support "weak"
// references (*), so we're left with managing the memory.
//
// (*) Yes, there is a WeakReference class, but it doesn't
// work exactly the way the Python weak reference works.
callback.delete();
callback = new JavaCallback();
System.out.println();
System.out.println("Adding and calling a Java callback");
System.out.println("------------------------------------");
caller.setCallback(callback);
caller.call();
caller.delCallback();
callback.delete();
System.out.println();
System.out.println("java exit");
}
}
class JavaCallback extends Callback
{
public JavaCallback()
{
super();
}
public void run()
{
System.out.println("JavaCallback.run()");
}
}