org.xml.* not in libgcj but libgij
Michael Matz
matz@suse.de
Mon Apr 18 18:37:00 GMT 2005
Hi,
I've not opened a bug yet, because I don't understand everything, and
because we need a local patch to make it happen.
So, first we have the problem, that the org.xml.* and
org.w3c.* classes (exactly those from the external/ subdir in libjava) are
not in libgcj anymore. Reading the archives it seems that they were
supposed to be provided by a different mean (endorsed dirs), but this
didn't work that well, so Tom partly reverted his initial patch in
http://gcc.gnu.org/ml/java-patches/2005-q1/msg00881.html
I think that revert itself was broken, because it did this:
-libgij_la_LIBADD = -L$(here)/.libs libgcj.la
+libgij_la_LIBADD = -L$(here)/.libs libgcj.la \
+ external/sax/libsax-gcj.la \
+ external/w3c_dom/libw3c-gcj.la
Note how it adds the external convenience libs to libgij, instead of
libgcj (like the mail, but not the changelog says). This break compiling
trang with gcj, as those classes can't be found anymore (and there are
also no jars or shared libs installed for them, as they are built only as
convenience libs). I think what Tom meant was to add them back to
libgcj_la_LIBADD (patch below). Note that this all is about natively
compiling, not to class files.
With that patch we get a little further, in that trang links. But it
doesn't work, for the same reasons for that also this testcase breaks to
run:
------------------------
import org.xml.sax.helpers.DefaultHandler;
public class A extends DefaultHandler {
public static void main (String[] args) {
System.out.println ("Hello.");
System.exit(0);
}
}
------------------------
(this testcase also can't be compiled without the patch btw).
The error message when running this is:
Exception in thread "main" java.lang.LinkageError: unexpected exception
duringlinking: A
at java.lang.VMClassLoader.transformException(java.lang.Class, java.lang.Throwable) (/usr/lib/libgcj.so.6.0.0)
at java.lang.VMClassLoader.resolveClass(java.lang.Class) (/usr/lib/libgcj.so.6.0.0)
at java.lang.Class.initializeClass() (/usr/lib/libgcj.so.6.0.0)
at A.main(java.lang.String[]) (Unknown Source)
at gnu.java.lang.MainThread.call_main() (/usr/lib/libgcj.so.6.0.0)
at gnu.java.lang.MainThread.run() (/usr/lib/libgcj.so.6.0.0)
Caused by: java.lang.NullPointerException
at java.lang.VMClassLoader.resolveClass(java.lang.Class) (/usr/lib/libgcj.so.6.0.0)
...4 more
We debugged this a bit, and the actuall segfault which causes the
NullPointerException is in _Jv_Linker::prepare_constant_time_tables at:
519 has_interfaces += klass0->interface_count;
because klass0 is 0x1, i.e. invalid pointer. This is because:
(gdb) p klass->superclass->superclass
$2 = 0x1
The actuall superclass with the broken superclass member is:
(gdb) p (char*)klass->superclass->name->data
$6 = 0x40abcf8a "org.xml.sax.helpers.DefaultHandler"
(gdb) p (char*)klass->name->data
$7 = 0x80493ee "A"
So, it seems that org.xml.sax.helpers.DefaultHandler is not correctly
initialized, although it is used in the internal structures. I tried to
set a breakpoint on _Jv_InitClass and
java::lang::VMClassLoader::resolveClass to see when exactly the org.xml.*
class is loaded/initialized, but it never happened.
So except the inclusion of the convenience libs into libgij also something
else must have been broken. I don't know enough about the java runtime to
move muc forward. I can't at least find something like a "go though all
classes and initialize them", or a class list, or something similar. So
my theory is that someone is responsible for initializing all classes in
one DSO, and for some reason this is forgotten for the org.xml (and w3c)
classes, even if the are now in the libgcj DSO.
Ciao,
Michael.
--
Index: libjava/Makefile.am
===================================================================
RCS file: /cvs/gcc/gcc/libjava/Makefile.am,v
retrieving revision 1.455.2.10
diff -u -r1.455.2.10 Makefile.am
--- libjava/Makefile.am 6 Apr 2005 21:38:10 -0000 1.455.2.10
+++ libjava/Makefile.am 18 Apr 2005 11:51:50 -0000
@@ -232,9 +232,7 @@
libgij_la_SOURCES = gij.cc
libgij_la_DEPENDENCIES = libgcj.la libgcj.spec
## See jv_convert_LDADD.
-libgij_la_LIBADD = -L$(here)/.libs libgcj.la \
- external/sax/libsax-gcj.la \
- external/w3c_dom/libw3c-gcj.la
+libgij_la_LIBADD = -L$(here)/.libs libgcj.la
## The mysterious backslash in the grep pattern is consumed by make.
libgij_la_LDFLAGS = -rpath $(toolexeclibdir) \
-version-info `grep -v '^\#' $(srcdir)/libtool-version` $(LIBGCJ_LD_SYMBOLIC)
@@ -272,6 +270,8 @@
-version-info `grep -v '^\#' $(srcdir)/libtool-version`
libgcj_la_LIBADD = \
libgcj0_convenience.la \
+ external/sax/libsax-gcj.la \
+ external/w3c_dom/libw3c-gcj.la
$(LIBFFI) $(ZLIBS) $(GCLIBS) $(propertyo_files)
libgcj_la_DEPENDENCIES = libgcj-$(gcc_version).jar \
java/lang/fdlibm.h java/lang/ieeefp.h java/lang/mprec.h \
More information about the Java
mailing list