[kaffe] JNI load

Helmer Krämer hkraemer@freenet.de
Fri, 20 Dec 2002 17:59:13 +0100


This is a multi-part message in MIME format.

--Multipart_Fri__20_Dec_2002_17:59:13_+0100_09167aa8
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit

On Fri, 20 Dec 2002 15:50:24 +0100
Richard Stahl <richard.stahl@imec.be> wrote:

Hi,

> I am sorry yet I again have a problem with the cvs version of kaffe 
> which I do not have with the release version!
>
> I am using JNI, so I used to specify the LD_LIBRARY_PATH to the place 
> where I have e.g. libMeta.so for class Meta.java ... (this works for the 
> release version!) yet it does not load the library and prints:
> 
> java.lang.ExceptionInInitializerError: [exception was 
> java.lang.UnsatisfiedLinkError: libMeta: not found]
>          at demo.main(demo.java:20)
> java.lang.UnsatisfiedLinkError: libMeta: not found
>          at java.lang.Throwable.fillInStackTrace(Throwable.java:native)
>          at java.lang.Throwable.<init>(Throwable.java:38)
>          at java.lang.Error.<init>(Error.java:81)
>          at java.lang.LinkageError.<init>(LinkageError.java:21)
>          at 
> java.lang.UnsatisfiedLinkError.<init>(UnsatisfiedLinkError.java:21)
>          at java.lang.Runtime.loadLibrary(Runtime.java:151)
>          at java.lang.System.loadLibrary(System.java:249)
>          at Meta.<clinit>(Meta.java:25)
>          at demo.main(demo.java:20)
> 
> Could you please give me some hints how to fix it.

I encountered the same  problem a few  days ago but
somehow didn't get around to send patches, sorry :(

When loading native libraries,  kaffe appends a few
different extensions to the name that was passed to
System.loadLibrary () and checks whether libtool is
able to load that file. What happens now is that
kaffe doesn't try the extension ".so" anymore since
the new libtool version (1.4.3) does not export the
autoconf macros necessary to figure out that ".so"
is the extension of dynamic libraries.

I've solved this by applying external.patch, so that
kaffe doesn't append the extensions itself but rather
lets libtool do that (by calling lt_dlopenext).

The next attached patch (libltdl.patch) is necessary
because lt_dlopenext contains a bug that prevents it
from trying to load  non-libtool libraries (the same
patch has been applied to libtool cvs  about 8 weeks
ago). 

Greetings,
Helmer
--Multipart_Fri__20_Dec_2002_17:59:13_+0100_09167aa8
Content-Type: application/octet-stream;
 name="libltdl.patch"
Content-Disposition: attachment;
 filename="libltdl.patch"
Content-Transfer-Encoding: base64

SW5kZXg6IGxpYmx0ZGwvbHRkbC5jCj09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KUkNTIGZpbGU6IC9jdnMva2FmZmUva2Fm
ZmUvbGlibHRkbC9sdGRsLmMsdgpyZXRyaWV2aW5nIHJldmlzaW9uIDEuMzIKZGlmZiAtdyAtdSAt
cCAtcjEuMzIgbHRkbC5jCi0tLSBsaWJsdGRsL2x0ZGwuYwkyIERlYyAyMDAyIDE0OjM1OjUzIC0w
MDAwCTEuMzIKKysrIGxpYmx0ZGwvbHRkbC5jCTIwIERlYyAyMDAyIDE2OjIzOjUyIC0wMDAwCkBA
IC0yOTg3LDcgKzI5ODcsNyBAQCBsdF9kbG9wZW5leHQgKGZpbGVuYW1lKQogICAgICBmYWlsZWQs
IGl0IGlzIGJldHRlciB0byByZXR1cm4gYW4gZXJyb3IgbWVzc2FnZSBoZXJlIHRoYW4gdG8KICAg
ICAgcmVwb3J0IEZJTEVfTk9UX0ZPVU5EIHdoZW4gdGhlIGFsdGVybmF0aXZlcyAoZm9vLnNvIGV0
YykgYXJlIG5vdAogICAgICBpbiB0aGUgbW9kdWxlIHNlYXJjaCBwYXRoLiAgKi8KLSAgaWYgKGhh
bmRsZSB8fCAoKGVycm9ycyA+IDApICYmIGZpbGVfbm90X2ZvdW5kICgpKSkKKyAgaWYgKGhhbmRs
ZSB8fCAoKGVycm9ycyA+IDApICYmICFmaWxlX25vdF9mb3VuZCAoKSkpCiAgICAgewogICAgICAg
TFRfRExGUkVFICh0bXApOwogICAgICAgcmV0dXJuIGhhbmRsZTsKQEAgLTMwMTQsNyArMzAxNCw3
IEBAIGx0X2Rsb3BlbmV4dCAoZmlsZW5hbWUpCiAKICAgLyogQXMgYmVmb3JlLCBpZiB0aGUgZmls
ZSB3YXMgZm91bmQgYnV0IGxvYWRpbmcgZmFpbGVkLCByZXR1cm4gbm93CiAgICAgIHdpdGggdGhl
IGN1cnJlbnQgZXJyb3IgbWVzc2FnZS4gICovCi0gIGlmIChoYW5kbGUgfHwgKChlcnJvcnMgPiAw
KSAmJiBmaWxlX25vdF9mb3VuZCAoKSkpCisgIGlmIChoYW5kbGUgfHwgKChlcnJvcnMgPiAwKSAm
JiAhZmlsZV9ub3RfZm91bmQgKCkpKQogICAgIHsKICAgICAgIExUX0RMRlJFRSAodG1wKTsKICAg
ICAgIHJldHVybiBoYW5kbGU7Cg==

--Multipart_Fri__20_Dec_2002_17:59:13_+0100_09167aa8
Content-Type: application/octet-stream;
 name="external.patch"
Content-Disposition: attachment;
 filename="external.patch"
Content-Transfer-Encoding: base64

SW5kZXg6IGthZmZlL2thZmZldm0vZXh0ZXJuYWwuYwo9PT09PT09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09ClJDUyBmaWxlOiAvY3Zz
L2thZmZlL2thZmZlL2thZmZlL2thZmZldm0vZXh0ZXJuYWwuYyx2CnJldHJpZXZpbmcgcmV2aXNp
b24gMS40MQpkaWZmIC13IC11IC1wIC1yMS40MSBleHRlcm5hbC5jCi0tLSBrYWZmZS9rYWZmZXZt
L2V4dGVybmFsLmMJMyBPY3QgMjAwMiAwNzowODo0OCAtMDAwMAkxLjQxCisrKyBrYWZmZS9rYWZm
ZXZtL2V4dGVybmFsLmMJMjAgRGVjIDIwMDIgMTY6NTU6MjUgLTAwMDAKQEAgLTY2LDcgKzY2LDcg
QEAgc3RhdGljIGlubGluZSB2b2lkIGtkbGZyZWUobHRfcHRyX3QgcHRyKQogI2VuZGlmCiAKICNp
Zm5kZWYgTElCUkFSWUxPQUQKLSNkZWZpbmUgTElCUkFSWUxPQUQoZGVzYyxmaWxlbmFtZSkJKChk
ZXNjKT1sdF9kbG9wZW4oKGZpbGVuYW1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