StackTraceElements (Was: [kaffe] Notes on kaffe (GNU Classpath integration) todo items)

Mark Wielaard mark at
Mon Jul 14 15:55:01 PDT 2003


On Mon, 2003-07-14 at 10:19, Helmer Krämer wrote:
> i've got a working version of this in my local tree
> (jetty for jdk 1.4 was working fine with it), but
> somehow didn't get around to commit it :( Could you
> probably post a patch of your implementation so I
> can fix and commit it?

I got rid of the crashes, but there are still some regression test
failures (some are just textual since the output of the stack trace is
different, but some seem real).

The attached patch merges from GNU Classpath which is
used as is and adds a Kaffe specific VMThrowable class that holds the
backtrace and provides the actual StackTraceElements when needed.

I have to admit that I actually did not really design it but just copied
bits and pieces of existing code of kaffevm. And C isn't really my
language of choice. So if you could do a review of what I have now that
would be great.

Here is a ChangeLog entry for the attached (gzipped) patch:

2003-07-14  Mark Wielaard  <mark at>
        * include/ (INSTALL_DERIVED_HDRS): Add
        java_lang_VMThrowable.h and java_lang_StackTraceElement.h.
        * include/ Regenerated.
        * kaffe/kaffevm/baseClasses.h (javaLangVMThrowable): New extern
        (javaLangStackTraceElement): Likewise.
        * kaffe/kaffevm/baseClasses.h (javaLangVMThrowable): New base class.
        (javaLangVMThrowable): Likewise.
        (initBaseClasses): loadStaticClass new base classes.
        * kaffe/kaffevm/exception.c (throwException): Get and initialize
        (nullException): Create vmstate for exception.
        (unhandledException): Use new Throwable->detailedMessage field name.
        (floatingException): Create vmstate for exception.
        * kaffe/kaffevm/stackTrace.c (getLineNumber): New method.
        (getStackTraceElements): New method.
        (printStackTrace): Get backtrace from vmState.
        * libraries/clib/native/System.c (java_lang_System_debugE): Use new
        Throwable->detailedMessage field name.
        * libraries/clib/native/Throwable.c
        (java_lang_Throwable_fillInStackTrace): Removed.
        (java_lang_Throwable_printStackTrace0): Likewise.
        (java_lang_VMThrowable_fillInStackTrace): New method.
        (java_lang_VMThrowable_getStackTrace): Likewise.
        * libraries/javalib/java/lang/ Replaced with Classpath
        * libraries/javalib/java/lang/ New class.
        * libraries/javalib/bootstrap.classlist: Add VMThrowable.
        * libraries/javalib/essential.files: Add StackTaceElement and
        * libraries/javalib/Klasses.jar.bootstrap: Regenerated.

With this patch the attached program gives the following stack trace:

   at Throw.testNull (
   at Throw.main (
   at Throw.testDivZero (
   at Throw.main (
java.lang.Exception: b confused
   at Throw.a (
   at Throw.testChain (
   at Throw.main (
Caused by: java.lang.Exception: d broken
   at Throw.c (
   at Throw.b (
   at Throw.a (
   ...2 more
Caused by: java.lang.Exception: fatal error
   at Throw.e (
   at Throw.d (
   at Throw.c (
   ...4 more

BTW how do you keep track of copyrights? I added a new copyright header
to every file I changed, but looking through the rest of the sources
this seems not customary.


-------------- next part --------------
A non-text attachment was scrubbed...
Type: text/x-java
Size: 1220 bytes
Desc: not available
Url : 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: throwable.patch.gz
Type: application/x-gzip
Size: 9984 bytes
Desc: not available
Url : 

More information about the kaffe mailing list