Will cni be the sane native interface to c++ in openjdk U gcj?

Andrew Haley aph@redhat.com
Tue Dec 25 12:03:00 GMT 2007


Glenn Chambers writes:
 > On Mon, 2007-12-24 at 13:51 -0800, ter wrote:
 > > Hi,
 > > 
 > > This is a development question from a user's point of view. Not a
 > > compiler writer myself. I am using swig (a great program) right now to
 > > write a java binding for an existing c++ library.  c++ is flattened to c
 > > on the native side, and then rebuilt back into objects on the java side.
 > > I understand cni is a much better approach. The binding from cni into
 > > full c++ would be much less complex, especially if the c++ code has good
 > > separation between interface and implementation.
 > 
 > It's been a few years since I last played seriously in this area, but at
 > that point, there were enough impedance mis-matches between C++ objects
 > and Java objects that C-style glue layers turned out to be necessary.
 > 
 > In particular, code that threw or caught C++ exceptions couldn't also
 > throw and catch Java exceptions.  This may have changed in recent
 > versions; I'll let the developers clarify that point.

This works fine, and has for a long while.  I don't know how long ago
you tried.

The rest of your suggestion looks pretty reasonable, but of course it
all depends on the particular library. 

Andrew.

-- 
Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SL4 1TE, UK
Registered in England and Wales No. 3798903



More information about the Java mailing list