Open Tianscar opened 8 months ago
I would love to support this feature, but I'm not sure I understand it!
Do you know where JNA does this in their codebase? We should be able to copy the same logic but it sounds like it will require work on the native side (to do the entire ffi_closure logic within the generated native stub).
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 theClosure
object, usingInvoker
to call the native method) and then useNativeMethods#register
to link theClosure#Handle
's function pointer to thenative
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:
JNA do the entire process of creating the
ffi_closure
and performingffi_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