SWIG CallBack from C++ into Java-Class

H

HalloUlrich

I tried from Java-Example in SWIG:

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();

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();

// Test that a double delete does not occur as the object has
already been deleted from the C++ layer.
// Note that the garbage collector can also call the delete()
method via the finalizer (callback.finalize())
// at any point after here.
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()");
}
}

***********************************************

But the Call into Java does not work. (Both callbacks only in c++).
Knows somebody why?

Regards, Ulrich
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,008
Latest member
Rahul737

Latest Threads

Top