How to map a native callback method to a java method
843829Feb 26 2002 — edited Mar 6 2002I need to build a JAVA API for an existing C++ library. I'm thinking about mapping the native functions to Java methods using JNI and encountered a problem on mapping the C++ callback function to a java method.
Assume there's a C++ class:
class Example {
public:
int foo() {
...
}
virtual int callback() {
}
}
Function callback() is implemented by a child class of Example. Whenever callback() is invoked in class Example, it'll perform the functionality implemented in the child class.
There's no problem to map a normal function like foo() to a java method such that the calling of java_foo() will invoke Example::foo() in native library. But I don't know how to map the callback() such that the call of Example::callback() in native library would actually invoke the java_callback() at java side.
Any suggestion/pointer/comments are greatly appreciated. Thanks in advance.
Baoshan