Native C calling Java method #320
paulocabrita-ionos
started this conversation in
General
Replies: 2 comments 1 reply
-
I'll convert this to a discussion, and we can go from there. |
Beta Was this translation helpful? Give feedback.
0 replies
-
There's a small example of using an interface to callback from C here: https://github.com/jnr/jnr-ffi-examples/blob/master/qsort/src/main/java/qsort/Qsort.java Does that help you? |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello.
I am having some issues in transforming a Pointer into a java object through a callback function (C is calling a Java Method).
My flow is as follows:
// calling native function. xpto is the native library. The second parameter is the Java method that the C native will call.
int ret = xpto.setAuthenticate(this.context, new JavaAuthenticateImpl());
// My class with the method called by Native C. I know that C calls this method because I can get the pointer address in Java. How to build a java object from the Pointer??
public class JavaAuthenticateImpl implements JavaAuthenticateCb {
}
// My interface.
public interface JavaAuthenticateCb {
@DeleGate
public boolean javaAuthenticateCb(Pointer context, Pointer token);
}
Are they some examples? I just can't find them.
Another thing, my native library has an include file with the description of all the C structs and they are ABI compliant. But, from my knowledge, JNR does not have the option to use ABI. But maybe I'm wrong.
How can I build a java object from a pointer inside a Java method that is called by a native function?
Thanks.
Beta Was this translation helpful? Give feedback.
All reactions