dynamic_cast problem in JNI code - any suggestions welcome.

Tom Tromey tromey@redhat.com
Tue Nov 12 19:24:00 GMT 2002


>>>>> "Jan" == Jan Hardenbergh <hardenbergh@rtviz.com> writes:

Jan> NOTE! this code runs FINE when used in another application. The
Jan> exact same shared object dies when run from Java thru JNI.

I gather you're using Sun's Java.  This list is really only for
discussion of gcj and related things.

Jan> Another thing I have noticed is that there are unresolved
Jan> references in our library that do not seem to get called,
Jan> however, when the library is opened in the JNI environment, it
Jan> wants all symbols resolved.

Jan> This seems to support the theory that some library involved in
Jan> dynamic linking is not compiled with the same compiler.

Jan> This crash does not happen if static_cast is used in place of
Jan> dynamic_cast.

libstdc++ has runtime support for dynamic_cast<> in it.  And, you must
use the libstdc++ corresponding to the compiler that you used to
compile your application -- you can't mix-and-match.

Also libgcc may play a role here.  Perhaps linking your shared library
against the correct versions of libgcc and libstdc++ will help.  I'm
not really certain.

If you continue to have problems with this, I suggest moving them to
the libstdc++ or gcc lists.  But most likely this issue has come up
before and been discussed -- try searching the list archives.

Tom



More information about the Java mailing list