I think it will be more convenient to use Java's built-in syntax, i.e. native method, to call native methods. "JNADirect" does this.
In order to do this with JFFI, I tried to create a Closure#Handle on the Java side (in the Closure object, using Invoker to call the native method) and then use NativeMethods#register to link the Closure#Handle's function pointer to the native method stub on the Java side.
But this is too slow, due to the whole process went through multiple calls back and forth between Java and native:
Java (downcall to native, method with `native` keyword)
-> native (upcall to Java, ffi closure)
-> Java (downcall to native, Java closure)
-> native (performing `ffi_call`)
-> the native method I wanna call
JNA do the entire process of creating the ffi_closure and performing ffi_call on the native side, which avoids multiple calls on the Java and native sides, ensures performance.
Could you consider adding this feature or adding some methods to a more efficient way implementing this feature?
Thanks in advance
I think it will be more convenient to use Java's built-in syntax, i.e.
nativemethod, to call native methods. "JNADirect" does this.In order to do this with JFFI, I tried to create a
Closure#Handleon the Java side (in theClosureobject, usingInvokerto call the native method) and then useNativeMethods#registerto link theClosure#Handle's function pointer to thenativemethod stub on the Java side.But this is too slow, due to the whole process went through multiple calls back and forth between Java and native:
JNA do the entire process of creating the
ffi_closureand performingffi_callon the native side, which avoids multiple calls on the Java and native sides, ensures performance.Could you consider adding this feature or adding some methods to a more efficient way implementing this feature?
Thanks in advance