Static build failing to load classes
Scott Gilbertson
scottg@mantatest.com
Wed Nov 16 22:56:00 GMT 2005
I'm trying to do a static build with today's gcj code. With a trivial java
program,
it crashes, apparently unable to load a class I'm reasonably sure is
included
in the binary. Is this a known problem?
My compile command:
/var/local/gcc/tip_20051115/bin/gcj -static --main=Hello -g -o Hello.bin
Hello.java
My GCJ and linux:
gcj (GCC) 4.1.0 20051116 (experimental)
(revision 107090 from SVN, checked out 2005年11月16日)
Linux version 2.6.8.1-10mdk
Here's the trivial source I'm trying to run with the interpreter. It works
OK when compiled to a dynamic executable, but not with a static build.
public class Hello
{
public static void main (String[] args)
{
System.out.println("hello");
}
}
>From the backtrace below, it seems like java.net.URLClassLoader.findClass
can't find
gnu.java.locale.LocaleInformation.class. I did "nm --defined-only Hello.bin
| grep LocaleInformation$"
and got:
08490f54 d _catch_classes_gnu.java.locale.LocaleInformation
08490f40 d _MT_gnu_java_locale_LocaleInformation
I think that means the gnu.java.locale.LocaleInformation class is included
in the binary, and therefore should have been loaded by the class loader.
Here's the backtrace for Hello.bin.
(gdb) bt
#0 0x082db9e1 in kill ()
#1 0x082c06aa in __pthread_raise ()
#2 0x082dbcc8 in abort ()
#3 0x080539ad in _Jv_Throw (value=0x4dc18) at
../../../gcc/libjava/exception.cc:111
#4 0x0004dc18 in ?? ()
#5 0x080f9530 in java.net.URLClassLoader.findClass(java.lang.String)
(this=0x61f50,
className=0x2b5b0) at URLClassLoader.java:1058
#6 0x080790b2 in
gnu.gcj.runtime.BootClassLoader.bootLoadClass(java.lang.String)
(this=0x61f50,
name=0x2b5b0) at BootClassLoader.java:55
#7 0x080733e2 in java::lang::VMClassLoader::loadClass (name=0x2b5b0,
resolve=0 '0円')
at ../../../gcc/libjava/java/lang/natVMClassLoader.cc:193
#8 0x0806ed14 in _Jv_FindClass (name=0x2dab0, loader=0x0)
at ../../../gcc/libjava/java/lang/natClassLoader.cc:304
#9 0x08049394 in _Jv_FindClassFromSignature (sig=0x8327a9e
"[Ljava.lang.String;", loader=0x0,
endp=0x0) at ../../../gcc/libjava/prims.cc:744
#10 0x08055364 in _Jv_Linker::resolve_pool_entry (klass=0x8482040,
index=157)
at ../../../gcc/libjava/link.cc:242
#11 0x080556e7 in _Jv_Linker::ensure_class_linked (klass=0x8482040)
at ../../../gcc/libjava/link.cc:1416
#12 0x080557cc in _Jv_Linker::wait_for_state (klass=0x8482040, state=9)
at ../../../gcc/libjava/link.cc:1732
#13 0x0806e0c1 in java::lang::Class::initializeClass (this=0x8482040)
at ../../../gcc/libjava/java/lang/natClass.cc:684
#14 0x0806e18e in java::lang::Class::initializeClass (this=0x847fe40) at
Class.h:584
#15 0x0807c0f3 in gnu.java.lang.MainThread.<clinit>() () at
MainThread.java:61
#16 0x0806e08d in java::lang::Class::initializeClass (this=0x847f480)
at ../../../gcc/libjava/java/lang/natClass.cc:739
#17 0x08049026 in _Jv_AllocObjectNoFinalizer (klass=0x847f480) at
Class.h:584
#18 0x08049049 in _Jv_AllocObject (klass=0x847f480) at
../../../gcc/libjava/prims.cc:448
#19 0x0804a0b3 in _Jv_RunMain (vm_args=0x0, klass=0x8479880, name=0x0,
argc=1, argv=0xbffff944,
is_jar=false) at ../../../gcc/libjava/prims.cc:1369
#20 0x0804a240 in _Jv_RunMain (klass=0x8479880, name=0x0, argc=1,
argv=0xbffff944, is_jar=false)
at ../../../gcc/libjava/prims.cc:1397
#21 0x0804a273 in JvRunMain (klass=0x8479880, argc=1, argv=0xbffff944)
at ../../../gcc/libjava/prims.cc:1403
#22 0x08048235 in main (argc=Cannot access memory at address 0x6) at
/root/tmp/cc4dqoZP.i:12
More information about the Java
mailing list