This is the mail archive of the java@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: JNI without dynamic linking?


>>>>> "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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]