[Kde-java] Re: GCJ (Re: Build system for KDE4)

Thomas Zander zander at kde.org
Wed Jun 15 22:50:16 CEST 2005


On Wednesday 15 June 2005 21:23, Martijn Klingens wrote:
> On Wednesday 15 June 2005 18:07, Tom Tromey wrote:
> > CNI isn't really a full C++/Java bridge.  There doesn't seem to be a
> > good way to make one, really, since C++ is so much more expressive
> > than Java.
> >
> > CNI is more like a convenient way to write native methods in C++, and
> > a way to access Java code from C++.
>
> Ok, to make sure that I get it right: if I have a C++ lib and want to
> write Java unit tests I would first need to wrap the C++ lib? That'd be
> a rather large setback for me.

As I understand it, using CNI its currently like this;

From Java you can't extend a C++ class (as all Java objects have to extend 
java.lang.Object).
From Java calling a method with native types (non objects) is impossible 
due to byte-ordering and stuff, you have to use jint in C++ instead.
All methods called in Java have to be defined in Java, much like header 
files in C++.  So if you want to call a method that returns a QString you 
need a java class QString.

This last point is the one you fear; but thats just from a compiling point 
of view.  I don't see any big reasons why most of this can't be automated 
or done on runtime.  But that needs investigation and probably code.

> Also, the other way round, writing a lib in Java and the tests in C++
> would be far more simple? (As that's exactly the case I do *NOT* need
> it's useless for me, but trying to get things straight.)

Apparently doing Java things from C++ has been the focus point of GCJ. Not 
the other way around.
Technology like gdirect (still alpha quality) can make various variable 
matching problems go away due to the design where loading the Java class 
for the first time will make it look up and create the native 'wrapper' 
code for you.
There does not seem to be a one-stop solution here; we will probably have 
to do some more thinking and possibly some auto-generating ourselves.
I have no good answer to this question right now.

-- 
Thomas Zander
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://mail.kde.org/pipermail/kde-java/attachments/20050615/9547c186/attachment.pgp


More information about the Kde-java mailing list