JNA doesn't "do" C++, at least not automatically. While C++ methods
may be exported from a shared library, several layers of translation
are needed before you can access C++ objects and methods
transparently. You need to interpret and generate mangled function
names before you can create an object, and then parse and dispatch
virtual function tables before you can invoke any methods on it.
It'd be cool to have some C++ layers on top of JNA, but I currently
have no reason to make them, so it's not likely to happen.
There are other offerings that claim to provide good C++ integration
(JNIEasy comes to mind, although "easy" might be a bit of a
stretch). I can't think of any free projects offhand, but there's a
list in the OTHERS file in the JNA root dir.
I don't know how well Swig handles wrapping objects and object
methods, or if it just exports a functional interface. If the
latter, you could just as well wrap your library in a few key 'extern
"C"' functions and use JNA.
On Dec 21, 2007, at 11:27 AM, Tim Emiola wrote:
Hi,
I apologise if this is already answered in the JNA documentation,
or elsewhere on the mailing list, but I looked I could not find
anything
clear.
I'm new to JNA - I'm evaluating the use of JNA as opposed to SWIG+JNI
for providing a java wrapper for some C++ libraries that I wish to use
from java. The C++ libraries are relatively stable, so I don't really
want to change anything about them, although at a push, I will be able
to tweak how they get built.
How do I access a C++ objects/methods in a shared library from JNA?
Is there any documentation about the best way to do this?