[kaffe] Is it a bug? System.loadLibrary() fails...
Dalibor Topic
robilad at yahoo.com
Wed Jan 15 16:39:02 PST 2003
Hi Seongboem,
--- "KIM, Seongbeom" <sbkim at mail.marusys.com> wrote:
> Sorry for late response...
>
> Updating sources does not help
> 'System.loadLibrary()' succeed.
> Making situation worse, it fails to load libawt when
> I try to run appletviewer.
> This does not happen if I go back to previous status
> (before update).
> I think it related with the extension-thing.
Does that happen with Qt-awt or Xlib awt or both?
> > > This is the source code for simple test
> > > application...
> > >
> > > ### begins here
> > > import java.lang.*;
> > > public class LoadTest
> > > {
> > > public static void main( String[] args )
> > > {
> > > System.loadLibrary( "pthread" );
> > > }
> > > };
> > > ### ends here
> > >
> > >
> > > When I executed the java application with Kaffe
> on
> > > my i386-linux-red hat 7.3,
> > > it failed with this message.
I've looked into this one. I've changed the example
code to:
import java.lang.*;
import java.util.*;
public class LibraryLoadTest {
public static void main( String[] args ) {
System.out.println(System.getProperties().getProperty("java.library.path"));
System.loadLibrary( "pthread" );
System.out.println("Success.");
}
};
With kaffe (CVS) I get
topic at clerks:~/Projects/Java/Kaffe/bugs/loadLib>
~/kaffe-pur/bin/kaffe LibraryLoadTest
/home/topic/kaffe-pur//jre/lib/i386:/home/topic/kaffe-pur//lib
java.lang.UnsatisfiedLinkError: libpthread: 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
LibraryLoadTest.main(LibraryLoadTest.java:7)
with kaffe 1.0.6 from SuSE 7.3 I get
topic at clerks:~/Projects/Java/Kaffe/bugs/loadLib> kaffe
LibraryLoadTest
/usr/local/lib/kaffe:/usr/local/lib
java.lang.UnsatisfiedLinkError: file 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:21)
at
java.lang.LinkageError.<init>(LinkageError.java:21)
at
java.lang.UnsatisfiedLinkError.<init>(UnsatisfiedLinkError.java:21)
at
java.lang.Runtime.loadLibrary(Runtime.java:147)
at
java.lang.System.loadLibrary(System.java:142)
at
LibraryLoadTest.main(LibraryLoadTest.java:7)
topic at clerks:~/Projects/Java/Kaffe/bugs/loadLib> kaffe
-fullversion
Kaffe Virtual Machine
Copyright (c) 1996-2000
Transvirtual Technologies, Inc. All rights reserved
Engine: Just-in-time v3 Version: 1.0.6 Java
Version: 1.1
Configuration/Compilation options:
Compile date : Don Mär 21 16:16:36 CET 2002
Compile host : clerks
Install prefix: /usr/local
Thread system : unix-jthreads
CC : gcc
CFLAGS : -g -O2 -Wall -Wstrict-prototypes
LDFLAGS : -export-dynamic
ChangeLog head: Tue Mar 19 21:40:47 PST 2002
Dalibor Topic <robilad at yahoo.com>
so far so bad. But now it get's really interesting as
with JDK 1.4.1_01 I get
topic at clerks:~/Projects/Java/Kaffe/bugs/loadLib>
/usr/lib/j2sdk1.4.1_01/bin/java LibraryLoadTest
/usr/lib/j2sdk1.4.1_01/jre/lib/i386/client:/usr/lib/j2sdk1.4.1_01/jre/lib/i386:/usr/lib/j2sdk1.4.1_01/jre/../lib/i386
Exception in thread "main"
java.lang.UnsatisfiedLinkError: no pthread in
java.library.path
at
java.lang.ClassLoader.loadLibrary(ClassLoader.java:1403)
at
java.lang.Runtime.loadLibrary0(Runtime.java:788)
at
java.lang.System.loadLibrary(System.java:832)
at
LibraryLoadTest.main(LibraryLoadTest.java:7)
But with Sun's JDK 1.1.8 I get a success:
topic at clerks:~/Projects/Java/Kaffe/bugs/loadLib>
/usr/lib/jdk1.1.8/bin/java LibraryLoadTest
null
Success.
So the next step was to define the java.library.path
property to "/usr/lib", where my libpthread is.
/usr/lib/j2sdk1.4.1_01/bin/java
-Djava.library.path=/usr/lib/ LibraryLoadTest
/usr/lib/
Success.
and it worked on JDK. On kaffe 1.0.6 and kaffe (CVS) I
get:
topic at clerks:~/Projects/Java/Kaffe/bugs/loadLib> kaffe
-Djava.library.path=/usr/lib/ LibraryLoadTest
Internal error: caught an unexpected exception.
Please check your CLASSPATH and your installation.
java/lang/UnsatisfiedLinkError: file 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:21)
at
java.lang.LinkageError.<init>(LinkageError.java:21)
at
java.lang.UnsatisfiedLinkError.<init>(UnsatisfiedLinkError.java:21)
at
java.lang.Runtime.loadLibrary(Runtime.java:147)
at
java.lang.System.loadLibrary(System.java:142)
at java.io.File.<clinit>(File.java:33)
at
kaffe.lang.SystemClassLoader.findResources(SystemClassLoader.java:48)
at
java.lang.ClassLoader.getResources(ClassLoader.java:187)
at
java.lang.ClassLoader.getResource(ClassLoader.java:164)
at
java.lang.ClassLoader.getResourceAsStream(ClassLoader.java:214)
at
java.lang.ClassLoader.getSystemResourceAsStream(ClassLoader.java:226)
at java.lang.System.<clinit>(System.java:45)
Abgebrochen
topic at clerks:~/Projects/Java/Kaffe/bugs/loadLib>
~/kaffe-pur/bin/kaffe -Djava.library.path=/usr/lib/
LibraryLoadTest
Internal error: caught an unexpected exception.
Please check your CLASSPATH and your installation.
java/lang/UnsatisfiedLinkError: libio: 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:250)
at java.io.File.<clinit>(File.java:35)
at
kaffe.lang.SystemClassLoader.findResources(SystemClassLoader.java:89)
at
java.lang.ClassLoader.getResources(ClassLoader.java:200)
at
java.lang.ClassLoader.getResource(ClassLoader.java:177)
at
java.lang.ClassLoader.getResourceAsStream(ClassLoader.java:227)
at
java.lang.ClassLoader.getSystemResourceAsStream(ClassLoader.java:239)
at java.lang.System.<clinit>(System.java:46)
at
java.lang.ThreadGroup.add(ThreadGroup.java:85)
Abgebrochen
but when I adapt java.library.path to include the
paths to kaffe's libs as well, it works:
topic at clerks:~/Projects/Java/Kaffe/bugs/loadLib>
~/kaffe-pur/bin/kaffe
-Djava.library.path=/home/topic/kaffe-pur/jre/lib/i386:/home/topic/kaffe-pur/lib:/usr/lib/
LibraryLoadTest
/home/topic/kaffe-pur/jre/lib/i386:/home/topic/kaffe-pur/lib:/usr/lib/
Success.
Finally, using LD_LIBRARY_PATH I get a success, too:
topic at clerks:~/Projects/Java/Kaffe/bugs/loadLib>
LD_LIBRARY_PATH=/usr/lib/ ~/kaffe-pur/bin/kaffe
LibraryLoadTest
/home/topic/kaffe-pur/jre/lib/i386:/home/topic/kaffe-pur/lib:/usr/lib/
Success.
the same on JDK 1.4.1:
topic at clerks:~/Projects/Java/Kaffe/bugs/loadLib>
LD_LIBRARY_PATH=/usr/lib/
/usr/lib/j2sdk1.4.1_01/bin/java LibraryLoadTest
/usr/lib/j2sdk1.4.1_01/jre/lib/i386/client:/usr/lib/j2sdk1.4.1_01/jre/lib/i386:/usr/lib/j2sdk1.4.1_01/jre/../lib/i386:/usr/lib/
Success.
So my conclusion is that while kaffe's has a bug when
compared to JDK 1.4.1 with respect to directly
defining java.libraries.path (and you probably
shouldn't do that), it is not behaving significantly
worse on this example. It implements Java 1.2
semantics with respect to Runtime.loadLibrary().
What you seem to want is the JDK 1.1 semantics, where
the library is apparently automatically searched for
in common library directories like /usr/lib. I'd like
to hear some comments if people think that would be a
desirable feature.
I am not in favor of Java 1.1 semantics, because
LD_LIBRARY_PATH works, is what Java 1.2 says we should
do (in Java Class Libraries 2nd Ed. Vol 1 Supplement,
the API spec for Java 1.4.1 is very vague), and allows
more flexibility with respect to testing with
different library versions (just change the path in
LD_LIBRARY_PATH). Of course, if you disagree, I'd like
to hear about it.
Fixing the exception message to mention
LD_LIBRARY_PATH would be a good idea, btw. Patches are
welcome ;)
best regards,
dalibor topic
__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com
More information about the kaffe
mailing list