Skip to Main Content

Java HotSpot Virtual Machine

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to map a native callback method to a java method

843829Feb 26 2002 — edited Mar 6 2002
I 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
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 3 2002
Added on Feb 26 2002
3 comments
848 views