GCJ .jar to .so with native method

Joe Hoffert jhoffert@dre.vanderbilt.edu
Thu Jan 10 21:39:00 GMT 2008

Hi, Andrew.

You had helped me very much last month trying to integrate Java and C++
using gcj/gcjh. I've run into problems (both using the gcj/gcjh .so
approach and the Java Invocation API approach). I can present details
about the specific problems but I'm wondering if you knew of problems in
general with generating a Java library using JDK 1.5 and then using
that .jar file with g++/gcj 4.1.2.

I needed to use both JDK and gcj since the Java source code uses
generics which gcj won't compile and I'm using g++ for my C++ compiler.
I had problems loading and calling the Java library using JDK 1.6 and g
++/gcj and then switched to compiling with JDK 1.5. This got me to my
present situation of segmentation errors showing up.

I'm suspecting the mixing of JDK and g++/gcj as a problem area because
of the problems I saw using JDK 1.6 and also because of the following. I
have C++ code that uses the Java Invocation API to load the Java library
and make calls into it. The Java library also has a native method that
calls back into C (and then C++).

However, I get strange segmentation errors from the JVM with the C++
code that is called back from the Java library. I have the C++ code
running in its own thread (spawned after the native method is invoked)
with the stack trace from the JVM crash showing all C/C++ code. I am
puzzled why the JVM would crash with a call stack like this. That's why
I'm suspecting a larger problem of JDK and g++/gcj not working well
together. Do you have experience with these types of problems?

I can provide more detail if that's helpful but I want to see if someone
else knows of problems mixing JDK 1.5 and g++/gcj 4.1.2 before I spend
any more time looking into this. Do you know of problems mixing JDK and

Thank you very much for all your help!


More information about the Gcc-help mailing list