JNA - calling methods upon C++ instance passed back from DLL

For any arbitrary type* function() definition you can map the method using JNA as returning a com.sun.jna.Pointer, but you won't be able to invoke methods on a C++ object from JNA.

A simple workaround for this would be to write a C interface library that simply invokes the method on the objects for you...so if you have some member function foo() you could export a C method from your C++ code:

extern "C" void bar(type* var){
   var->foo();
}

Obviously this will add some work for you...but I suspect the overhead for switching to JNI would be about the same.

Tags:

Java

Jna