This question is that you are asking how to invoke C ++ instance methods using JNA , and it is possible, but you will have to do some work. In particular, you need to write a shell in which extern "C" has any functions that you really should call.
For any arbitrary definition of type* function() you can map the method using JNA as returning com.sun.jna.Pointer , but you cannot call methods on a C ++ object from JNA.
A simple workaround for this would be to write a C interface library that simply calls the method for the objects for you ... so if you have a foo() member function, you can export the C method from your C ++ code:
extern "C" void bar(type* var){ var->foo(); }
Obviously, this will add some work to you ... but I suspect that the overhead for going to JNI will be about the same.
JNA only cares about how this method is exported to a DLL - and it should be without C ++ decorations (hence extern "C" ), so you can do whatever you need in any such method without exposing the methods to you are calling.
In my far-fetched example above, this means that foo() , if defined in a DLL, should not actually even display. Since this is a C ++ function, JNA cannot call it directly, but it can be called from a function that JNA can call, so my proposed solution works.
So yes, you can completely encapsulate calls to all member functions (create, manage, destroy) in one function, and JNA doesn't care.
Mark elliot
source share