Can't get Throwable.printStackTrace when statically linked

Scott Gilbertson
Fri Nov 22 10:46:00 GMT 2002

I don't get stack dumps when there's a Java exception in my
statically-linked binary (works fine in dynamic linked version).  The
following backtrace is from a core file generated from a Java exception.
Since there's no stack dump printed, I don't know the original cause of the

I see the following line in
  String className = "gnu.gcj.convert.Output_" + encoding;
so I assume it's failing to find Output_something.class.

Does anyone know a simple way to ensure that all the classes I need are in
the executable, or do I just have to add "-u" entries to my link arguments
whenever I find one missing?

UnicodeToBytes.getDefaultEncoder has a try/catch that should have caught the
classloader failure, resulting in "return new Output_8859_1();", so why did
the program abort?


(gdb) bt
#0  0x08168c51 in kill ()
#1  0x08155876 in raise ()
#2  0x08168fad in abort ()
#3  0x080a7264 in _Jv_Throw (value=0x83ecff0) at
#4  0x0809d60c in catch_segv (_dummy=138334192) at
#5  0x0809d621 in catch_segv(int) () at ../../../gcc/libjava/
#6  <signal handler called>
#7  0x08184006 in __current_locale_name ()
#8  0x081659bd in guess_category_value ()
#9  0x08164fd6 in __dcigettext ()
#10 0x08164d52 in dcgettext ()
#11 0x08175cbe in strerror_r ()
#12 0x08175bc4 in strerror ()
#13 0x0815aba4 in dlerror ()
#14 0x081120f4 in sys_dl_open (loader_data=0x0, filename=0xbf5ff84c
    at ../../../../gcc/libjava/libltdl/ltdl.c:299
#15 0x0811264f in tryall_dlopen (handle=0xbf5ff7e4, filename=0xbf5ff84c
    at ../../../../gcc/libjava/libltdl/ltdl.c:937
#16 0x08113269 in lt_dlopen (filename=0xbf5ff84c
    at ../../../../gcc/libjava/libltdl/ltdl.c:1511
#17 0x08113daf in lt_dlopenext (filename=0xbf5ff84c
    at ../../../../gcc/libjava/libltdl/ltdl.c:1573
#18 0x080bf45b in
java::lang::Runtime::loadLibraryInternal(java::lang::String*) (this=0x40,
    at ../../../gcc/libjava/java/lang/
#19 0x080bd0ff in
(this=0x83f3f90, name=0x848b730)
    at ../../../gcc/libjava/java/lang/
#20 0x080c627e in java.lang.ClassLoader.loadClass(java.lang.String, boolean)
(this=0x83f3f90, name=0x848b730,
    link=false) at ../../../gcc/libjava/java/lang/
#21 0x080bd68f in _Jv_FindClass(_Jv_Utf8Const*, java::lang::ClassLoader*)
(name=0x84190f0, loader=0x0)
    at ../../../gcc/libjava/java/lang/
#22 0x080ba6e2 in java::lang::Class::forName(java::lang::String*, bool,
java::lang::ClassLoader*) (
    className=0x840f610, initialize=1 '\001', loader=0x0) at
#23 0x080ba77a in java::lang::Class::forName(java::lang::String*)
    at ../../../gcc/libjava/java/lang/
#24 0x08101c41 in gnu.gcj.convert.UnicodeToBytes.getDefaultEncoder() ()
    at ../../../gcc/libjava/gnu/gcj/convert/
#25 0x08122803 in
(this=0x8470a08, out=0x83f3ea0)
    at ../../../gcc/libjava/java/io/
#26 0x080d046c in
(this=0x840f690, out=0x83f3ea0)
    at ../../../gcc/libjava/java/io/
#27 0x080cd848 in java.lang.Throwable.printStackTrace(
(this=0x83ecff0, ps=0x83f3ea0)
    at ../../../gcc/libjava/java/lang/
#28 0x08092f74 in manta::mts5000::hardware::TimingBoardDriver::eventRxLoop()
#29 0x0809193a in manta::mts5000::hardware::TimingBoardDriver$1::run() ()
#30 0x080c2815 in _Jv_ThreadRun(java::lang::Thread*) (thread=0x83f7910)
    at ../../../gcc/libjava/java/lang/
#31 0x08106aa3 in really_start (x=0x8415ff0) at
#32 0x0810b432 in GC_start_routine (arg=0x83d5fc0) at
#33 0x081537b1 in pthread_start_thread ()

More information about the Java mailing list