This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
Re: JNI without dynamic linking?
- To: martin dot kahlert at infineon dot com
- Subject: Re: JNI without dynamic linking?
- From: Tom Tromey <tromey at redhat dot com>
- Date: 27 Apr 2001 10:23:48 -0600
- Cc: java at gcc dot gnu dot org
- References: <20010426101738.A24431@keksy.muc.infineon.com>
- Reply-To: tromey at redhat dot com
>>>>> "Martin" == Martin Kahlert <martin.kahlert@infineon.com> writes:
Martin> Is it possible to add native functions to java progs statically?
Maybe. I have never tried it. In theory it should work though.
Martin> I deleted this and linked the files with the C functions statically.
If static linking removes the symbol information then that would cause
the problem you are seeing.
If the JNI code appears in a .a library and you statically link then
chances are that the code simply won't be linked in at all -- there
will be no references to it, so the linker will discard it.
Martin> This does not work (exception at load).
Martin> The difference seems to be that _Jv_FindSymbolInExecutable is called
Martin> twice, the name of the C function and additionally with its mangled
Martin> name.
Martin> The second call is missing if i use the dynamic linked variant
Martin> by providing a libname.so.
In JNI there are two ways to mangle most function names. We try both
in order, like the JNI spec specifies. You only see the second call
in the static case because the first lookup attempt is failing -- that
is the real problem.
Martin> The symbols seem to be searched for in all libraries and after
Martin> that inside the executable itself (by dlsym(NULL....)), so
Martin> this should work.
I agree.
Try running `nm' on the final executable and see if the functions are
there.
Tom