shared libraries
Anthony Green
green@redhat.com
Sun Sep 16 18:26:00 GMT 2001
I've noticed an annoying problem while working with shared libraries
and Class.forName().
If the class loader finds the proper .so, Class.forName() may still
throw a ClassNotFoundException if that .so hasn't been linked with
every .so it depends on at runtime (unless those libraries have
already been loaded, libgcj.so).
The linker certainly doesn't complain about this at link time, and
there doesn't appear to be any convenient way to figure out the
dependencies. I've been reduced to tricks like...
$ LD_PRELOAD=lib-Foo.so ls
ls: error while loading shared libraries: /home/green/lib/lib-Foo.so: undefined symbol: _ZN3Bar3bar6class$E
This tells me I have to link the .so containing Bar.bar when I create
lib-Foo.so or else `Class.forName("Foo.foo")' will fail.
Is there any easier way to deal with this?
AG
More information about the Java
mailing list