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

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


Hi,

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 Throwable.java 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 klomp.org>
                                                                                
        * include/Makefile.am (INSTALL_DERIVED_HDRS): Add
        java_lang_VMThrowable.h and java_lang_StackTraceElement.h.
        * include/Makefile.in: Regenerated.
        * kaffe/kaffevm/baseClasses.h (javaLangVMThrowable): New extern
        struct.
        (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
        vmstate.
        (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/Throwable.java: Replaced with Classpath
        version.
        * libraries/javalib/java/lang/VMThrowable.java: New class.
        * libraries/javalib/bootstrap.classlist: Add VMThrowable.
        * libraries/javalib/essential.files: Add StackTaceElement and
        VMThrowable.
        * libraries/javalib/Klasses.jar.bootstrap: Regenerated.

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

java.lang.NullPointerException
   at Throw.testNull (Throw.java:17)
   at Throw.main (Throw.java:5)
 
java.lang.ArithmeticException
   at Throw.testDivZero (Throw.java:30)
   at Throw.main (Throw.java:7)
 
java.lang.Exception: b confused
   at Throw.a (Throw.java:58)
   at Throw.testChain (Throw.java:42)
   at Throw.main (Throw.java:9)
Caused by: java.lang.Exception: d broken
   at Throw.c (Throw.java:75)
   at Throw.b (Throw.java:64)
   at Throw.a (Throw.java:54)
   ...2 more
Caused by: java.lang.Exception: fatal error
   at Throw.e (Throw.java:86)
   at Throw.d (Throw.java:81)
   at Throw.c (Throw.java:71)
   ...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.

Cheers,

Mark
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Throw.java
Type: text/x-java
Size: 1220 bytes
Desc: not available
Url : http://kaffe.org/pipermail/kaffe/attachments/20030714/170510d8/attachment-0002.java 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: throwable.patch.gz
Type: application/x-gzip
Size: 9984 bytes
Desc: not available
Url : http://kaffe.org/pipermail/kaffe/attachments/20030714/170510d8/attachment-0002.bin 


More information about the kaffe mailing list