Incorrect Java methods called from CNI
Dave Menendez
dave@sycamore.us
Fri May 7 20:48:00 GMT 2004
I'm hoping that someone else has seen this problem and knows of a
possible workaround or fix. I am using GCC 3.4.0 and GCJ to compile
several Java -source- files. I use gcjh to generate header files for
all these Java files. I have some C++ code that successfully
instantiates the Java object and calls some methods on it. So far,
things are working great.
However, I've just run into a problem that didn't seem to make any
sense, and by adding a few basic System.out.println statements directly
in the Java source and regenerating all the files, I've determined that
the method I invoke from C++ is actually calling the wrong method on the
Java object. For example, in C++ I invoked SomeJavaObj->clear(), but
according to the println's I placed in the Java object itself,
SomeJavaObj.add() was the actual method that got invoked.
Other methods work, but this is the first one I've come across where the
wrong method altogether was invoked. The method I'm calling isn't
anything out of the ordinary, like an implementation of an interface
method, and the pointer I'm using is a pointer of the actual class type,
not of an interface type, so I don't think I'm doing anything wacky
here. I even tried compiling without any optimization (-O0) instead of
the default used by autoconf/automake (-O2).
More information about the Java
mailing list