Exceptions work now with nested builtin_news correctly (set the exception pointer...
authorjowenn <none@none>
Mon, 31 May 2004 15:47:20 +0000 (15:47 +0000)
committerjowenn <none@none>
Mon, 31 May 2004 15:47:20 +0000 (15:47 +0000)
40 files changed:
asmpart.h
builtin.c
global.h
headers.c
jit/codegen.inc
jit/i386/asmpart.S
jit/i386/codegen.c
jit/jit.c
jit/stack.c
jni.c
loader.c
loader.h
nat/JOWENNTest1.c
nat/VMThrowable.c
nat/classcontextnativeTest.c
native.c
src/cacaoh/headers.c
src/native/jni.c
src/native/native.c
src/native/vm/VMThrowable.c
src/vm/builtin.c
src/vm/global.h
src/vm/jit/asmpart.h
src/vm/jit/codegen.inc
src/vm/jit/i386/asmpart.S
src/vm/jit/i386/codegen.c
src/vm/jit/jit.c
src/vm/jit/stack.c
src/vm/loader.c
src/vm/loader.h
tests/extest.java
tests/stack/README [new file with mode: 0644]
tests/stack/exception.java
tests/stack/inheritancetest.java [new file with mode: 0644]
tests/stack/java/Makefile
tests/stack/java/stackTraceTest1.c
tests/stack/java/stackTraceTest1.java
tests/stack/nestedconstructorexception.java [new file with mode: 0644]
tests/stack/nestedconstructorexception2.java [new file with mode: 0644]
tests/stack/nestedstaticinitializers.java [new file with mode: 0644]

index d6a205dd4446e5fe7600b18307d9e334d4723db6..a8ff334c987701e0a1196daccb599792f5cde9b3 100644 (file)
--- a/asmpart.h
+++ b/asmpart.h
@@ -29,7 +29,7 @@
 
    Changes: Christian Thalinger
 
-   $Id: asmpart.h 1082 2004-05-26 15:04:54Z jowenn $
+   $Id: asmpart.h 1112 2004-05-31 15:47:20Z jowenn $
 
 */
 
@@ -84,7 +84,7 @@ void asm_handle_nat_exception();
 void asm_check_clinit();
 
 void asm_handle_builtin_exception(classinfo *);
-void asm_throw_and_handle_hardware_nullpointer_exception();
+void asm_throw_and_handle_exception();
 void asm_throw_and_handle_hardware_arithmetic_exception();
 
 java_objectarray* Java_java_lang_VMSecurityManager_getClassContext(JNIEnv *env, jclass clazz);
index 12addc485be777300492bbdd1a08acd7c5d7ca3e..017eb1aea9a5dbe232481ecc23a559ac343780c2 100644 (file)
--- a/builtin.c
+++ b/builtin.c
@@ -34,7 +34,7 @@
    calls instead of machine instructions, using the C calling
    convention.
 
-   $Id: builtin.c 1085 2004-05-26 18:52:37Z twisti $
+   $Id: builtin.c 1112 2004-05-31 15:47:20Z jowenn $
 
 */
 
@@ -1812,7 +1812,7 @@ stacktraceelement *builtin_stacktrace_copy(stacktraceelement **el,stacktraceelem
        size_t s;
        s=(end-begin);
        /*printf ("begin: %p, end: %p, diff: %ld, size :%ld\n",begin,end,s,s*sizeof(stacktraceelement));*/
-       *el=GCNEW(stacktraceelement,s+1);
+       *el=MNEW(stacktraceelement,s+1); /*GC*/
        memcpy(*el,begin,(end-begin)*sizeof(stacktraceelement));
        (*el)[s].method=0;
 #warning change this if line numbers bigger than u2 are allowed, the currently supported class file format does no allow that
index 8a42b80f8aa8a19b9be4327a6b283d30a9c3dd38..6b5f42399ba87141c1bcc0ad08a3241ff389e178 100644 (file)
--- a/global.h
+++ b/global.h
@@ -31,7 +31,7 @@
             Philipp Tomsich
                        Edwin Steiner
 
-   $Id: global.h 1082 2004-05-26 15:04:54Z jowenn $
+   $Id: global.h 1112 2004-05-31 15:47:20Z jowenn $
 
 */
 
@@ -322,7 +322,7 @@ typedef struct stacktraceelement stacktraceelement;
 /* data structure for calls from c code to java methods */
 
 struct jni_callblock {
-       u1 itemtype;
+       u8 itemtype;
        u8 item;
 };
 
index d455b5c2937861f2ab8bec4fa313685944905002..07d8a05c44474fa93cac5cdbbb3435d637aaa2f9 100644 (file)
--- a/headers.c
+++ b/headers.c
@@ -29,7 +29,7 @@
    Changes: Mark Probst
             Philipp Tomsich
 
-   $Id: headers.c 1097 2004-05-27 15:58:34Z twisti $
+   $Id: headers.c 1112 2004-05-31 15:47:20Z jowenn $
 
 */
 
@@ -693,6 +693,7 @@ int main(int argc, char **argv)
        fprintf(file, "#define offobjarrdata  %3d\n\n", (int) OFFSET(java_objectarray, data[0]));
        fprintf(file, "#define offbaseval     %3d\n", (int) OFFSET(vftbl, baseval));
        fprintf(file, "#define offdiffval     %3d\n\n", (int) OFFSET(vftbl, diffval));
+       fprintf(file, "#define offclass     %3d\n\n", (int) OFFSET(vftbl, class));
 
        fprintf(file, "#define offclassvftbl  %3d\n", (int) OFFSET(classinfo, vftbl));
        fprintf(file, "#define offclassinit   %3d\n", (int) OFFSET(classinfo, initialized));
index 7ca7b29f483b2bcd8ba99c5752b9bbe29704bc5c..de678d16fbffa29285bcd755e8472dd2a58a2dcd 100644 (file)
@@ -48,7 +48,7 @@
    memory. All functions writing values into the data area return the offset
    relative the begin of the code area (start of procedure).   
 
-   $Id: codegen.inc 1099 2004-05-27 16:06:14Z twisti $
+   $Id: codegen.inc 1112 2004-05-31 15:47:20Z jowenn $
 
 */
 
@@ -501,6 +501,22 @@ static int methodtree_comparator(const void *pc, const void *element,
 }
 
 
+#if 0
+void *codegen_findmethod1(void *pc)
+{
+       void * retVal=findmethod(pc);
+       methodinfo **ma=(methodinfo**)retVal;
+       methodinfo *m=ma[-1];
+       if (m)
+               if (m->name)
+                       utf_display(m->name);
+               else 
+                       log_text("No Name");
+       else log_text("No methodinfo");
+       return retVal;
+}
+#endif
+
 void *codegen_findmethod(void *pc)
 {
 #if 1
index a534e6da3722178c54a9cf4a29624c8e4beed1d0..7aff7a23e1e4317207a7fad50819b50d4ab56ea0 100644 (file)
@@ -29,7 +29,7 @@
             Reinhard Grafl
             Christian Thalinger
 
-   $Id: asmpart.S 1111 2004-05-29 07:51:40Z jowenn $
+   $Id: asmpart.S 1112 2004-05-31 15:47:20Z jowenn $
 
 */
 
        .globl builtin_trace_exception
        .globl class_java_lang_Object
        .globl codegen_findmethod
+/*     .globl codegen_findmethod1*/
        .globl builtin_asm_createclasscontextarray
        .globl builtin_asm_getclassloader
        .globl callgetexceptionptrptr
-       .globl asm_throw_and_handle_hardware_nullpointer_exception
+       .globl asm_throw_and_handle_exception
        .globl asm_throw_and_handle_hardware_arithmetic_exception
 
 
@@ -394,6 +395,44 @@ L_exception:
        pop     %ecx                /* delete return address                      */
        sub     $2,%ecx             /* faulting address is return adress - 2      */
 
+L_refillinStacktrace:
+       push %ecx               /* store fault adress */
+       push %eax               /* temporarily save exception pointer*/
+       call builtin_asm_get_stackframeinfo
+       push %eax       /* save location of thread specific stack info head pointer */
+       mov (%eax),%ecx /* save old value of pointer*/
+       push %ecx
+       mov %esp,(%eax) /*store pointer to this structure*/
+       mov 8(%esp),%eax  /* get the exception pointer again*/
+       movl $0,8(%esp) /*mark this block as native*/
+       push $0 /*used for the jni_callblock structure*/
+       push %eax /*save eax for later */
+       /* get fillInStackTrace method*/
+       push utf_fillInStackTrace_desc
+       push utf_fillInStackTrace_name
+       mov offobjvftbl(%eax),%ecx
+       mov offclass(%ecx),%eax
+       push %eax
+       call class_resolvemethod
+       add $12,%esp
+       push $0
+       push $4 /*TYPE_ADR*/
+       push %esp
+       push $sizejniblock
+       push $1
+       push %eax
+       call asm_calljavafunction2
+       add $24,%esp
+
+       /*remove native stack info */
+       mov 8(%esp),%ecx
+       mov 12(%esp),%eax
+       mov %ecx,(%eax)
+       mov (%esp),%eax
+       add $20,%esp
+       pop %ecx
+
+       
        jmp     asm_handle_exception
 
 
@@ -432,7 +471,7 @@ asm_handle_exception_loop:
                push    %eax                                            /* save exception pointer         */
                push    %ecx                        /* save exception pc              */
 
-       call    codegen_findmethod          /* get the data segment ptr           */
+               call    codegen_findmethod          /* get the data segment ptr           */
                mov     %eax,%edx
                        
                mov     -4(%ebp),%eax
@@ -709,6 +748,12 @@ asm_builtin_monitorenter:
        jmp             builtin_monitorenter        /* else call builtin_monitorenter     */
 
 nb_monitorenter:
+        mov string_java_lang_NullPointerException,%eax
+        pop %ecx
+        sub $2,%ecx
+        jmp asm_throw_and_handle_exception
+
+#if 0
        push    string_java_lang_NullPointerException
        call    new_exception
        add     $(1*4),%esp
@@ -716,7 +761,7 @@ nb_monitorenter:
        pop     %ecx                        /* delete return address              */
        sub     $2,%ecx                     /* faulting address is return adress - 2 */
        jmp     asm_handle_exception
-               
+#endif         
 
 /********************* function asm_builtin_monitorexit ************************
 *                                                                              *
@@ -738,6 +783,12 @@ asm_builtin_monitorexit:
     ret
 
 nb_monitorexit:
+        mov string_java_lang_NullPointerException,%eax
+        pop %ecx
+        sub $2,%ecx
+        jmp asm_throw_and_handle_exception
+
+#if 0
        push    string_java_lang_NullPointerException
        call    new_exception
        add     $(1*4),%esp
@@ -745,7 +796,7 @@ nb_monitorexit:
        pop     %ecx                    /* delete return address              */
        sub     $2,%ecx                 /* faulting address is return adress - 2 */
        jmp     asm_handle_exception
-
+#endif
 
 /************************ function asm_builtin_ldiv ****************************
 *                                                                              *
@@ -762,6 +813,10 @@ asm_builtin_ldiv:
        jmp     builtin_ldiv
 
 nb_ldiv:
+       pop %ecx
+       sub $2,%ecx
+       jmp asm_throw_and_handle_hardware_arithmetic_exception
+#if 0
        push    string_java_lang_ArithmeticException_message
        push    string_java_lang_ArithmeticException
        call    new_exception_message
@@ -770,7 +825,7 @@ nb_ldiv:
        pop     %ecx                        /* delete return address              */
        sub     $2,%ecx                     /* faulting address is return adress - 2 */
        jmp     asm_handle_exception
-                               
+#endif                         
 
 /************************ function asm_builtin_lrem ****************************
 *                                                                              *
@@ -787,6 +842,10 @@ asm_builtin_lrem:
        jmp     builtin_lrem
 
 nb_lrem:
+       pop %ecx
+       sub $2,%ecx
+       jmp asm_throw_and_handle_hardware_arithmetic_exception
+#if 0
        push    string_java_lang_ArithmeticException_message
        push    string_java_lang_ArithmeticException
        call    new_exception_message
@@ -795,7 +854,7 @@ nb_lrem:
        pop     %ecx                        /* delete return address              */
        sub     $2,%ecx                     /* faulting address is return adress - 2 */
        jmp     asm_handle_exception
-               
+#endif         
 
 /************************ function asm_builtin_x2x *****************************
 *                                                                              *
@@ -857,6 +916,12 @@ asm_builtin_checkarraycast:
        ret
 
 nb_carray_throw:
+       add $8,%esp
+       mov string_java_lang_ClassCastException,%eax
+       pop %ecx
+       sub $2,%ecx
+       jmp asm_throw_and_handle_exception
+#if 0
        push    string_java_lang_ClassCastException
        call    new_exception
        add     $(1*4),%esp
@@ -866,7 +931,7 @@ nb_carray_throw:
        pop             %ecx                        /* delete return address              */
        sub             $2,%ecx                     /* faulting address is return adress - 2 */
        jmp             asm_handle_exception
-
+#endif
                
 /******************* function asm_builtin_newarray *****************************
 *                                                                              *
@@ -931,6 +996,13 @@ asm_builtin_aastore:
        ret
 
 nb_aastore_null:
+        add $12,%esp
+        mov string_java_lang_NullPointerException,%eax
+        pop %ecx
+        sub $2,%ecx
+        jmp asm_throw_and_handle_exception
+
+#if 0
        push    string_java_lang_NullPointerException
        call    new_exception
        add     $(1*4),%esp
@@ -939,7 +1011,7 @@ nb_aastore_null:
        pop     %ecx                        /* delete return address              */
        sub     $2,%ecx                     /* faulting address is return adress - 2 */
        jmp             asm_handle_exception
-
+#endif
 nb_aastore_bound:
        push    %ecx                        /* itmp2 contains array index         */
        push    string_java_lang_ArrayIndexOutOfBoundsException
@@ -952,6 +1024,14 @@ nb_aastore_bound:
        jmp     asm_handle_exception
                
 nb_aastore_store:
+       add     $12,%esp
+
+        mov string_java_lang_ArrayStoreException,%eax
+        pop %ecx
+        sub $2,%ecx
+        jmp asm_throw_and_handle_exception
+
+#if 0
        push    string_java_lang_ArrayStoreException
        call    new_exception
        add     $(1*4),%esp
@@ -960,7 +1040,7 @@ nb_aastore_store:
        pop     %ecx                        /* delete return address              */
        sub     $2,%ecx                     /* faulting address is return adress - 2 */
        jmp     asm_handle_exception
-
+#endif
                
 /******************* function asm_builtin_arrayinstanceof **********************
 *                                                                              *
@@ -1253,10 +1333,10 @@ getClassContext_leave:
        ret
 
 
-asm_throw_and_handle_hardware_nullpointer_exception:
+asm_throw_and_handle_exception:
        sub $20,%esp /*build stack frame*/
        mov %ecx,16(%esp) /*save eip of problem */
-       
+       mov %eax,(%esp)
        movl $0,12(%esp) /*internal function -> no function description */
        call builtin_asm_get_stackframeinfo
        mov %eax,8(%esp)
@@ -1266,8 +1346,8 @@ asm_throw_and_handle_hardware_nullpointer_exception:
        add $4,%ecx
        mov %ecx,(%eax)
        
-       mov string_java_lang_NullPointerException,%eax
-       mov %eax,(%esp)
+/*     mov string_java_lang_NullPointerException,%eax
+       mov %eax,(%esp)*/
         call new_exception
        push %eax
        mov 8(%esp),%eax
index 7c3e8b2b5c1510a30fb407d8660e0edd6f4f6e93..2885f9616e07a241ac7d4c37bfc0a0310a4505ea 100644 (file)
@@ -28,7 +28,7 @@
    Authors: Andreas Krall
             Christian Thalinger
 
-   $Id: codegen.c 1102 2004-05-27 16:30:45Z twisti $
+   $Id: codegen.c 1112 2004-05-31 15:47:20Z jowenn $
 
 */
 
@@ -320,6 +320,10 @@ void codegen_stubcalled() {
        log_text("Stub has been called");
 }
 
+void codegen_general_stubcalled() {
+       log_text("general exception stub  has been called");
+}
+
 
 #if defined(USE_THREADS) && defined(NATIVE_THREADS)
 void thread_restartcriticalsection(ucontext_t *uc)
@@ -383,7 +387,8 @@ void catch_NullPointerException(int sig, siginfo_t *siginfo, void *_p)
                sigprocmask(SIG_UNBLOCK, &nsig, NULL);           /* unblock signal    */
 
                sigctx->ecx = sigctx->eip;                       /* REG_ITMP2_XPC     */
-               sigctx->eip = (u4) asm_throw_and_handle_hardware_nullpointer_exception;
+               sigctx->eax=string_java_lang_NullPointerException;
+               sigctx->eip = (u4) asm_throw_and_handle_exception;
                
                return;
 
@@ -4019,31 +4024,6 @@ gen_method: {
 
                        MCODECHECK((s3 << 1) + 64);
 
-                       if ( (iptr->opc == ICMD_BUILTIN1) ||
-                               (iptr->opc == ICMD_BUILTIN2) ||
-                               (iptr->opc == ICMD_BUILTIN3) ) {
-#if 0
-                               i386_push_reg(REG_ITMP1);
-                               i386_push_reg(REG_ITMP2);
-                               i386_push_reg(REG_ITMP3);
-
-                               i386_mov_imm_reg((s4) builtin_asm_new_stackframeinfo, REG_ITMP1);
-                               i386_call_reg(REG_ITMP1);
-
-                               i386_pop_reg(REG_ITMP3);
-                               i386_pop_reg(REG_ITMP2);
-                               i386_pop_reg(REG_ITMP1);
-
-#if 0
-                               i386_mov_membase_reg(REG_SP, 0 , REG_ITMP2); /*save return adress*/
-                               i386_mov_membase_reg(REG_RESULT, 0 , REG_ITMP3); /*get direct access to structure*/
-
-                               i386_mov_imm_membase(0x1111, REG_ITMP3, offreturnfromnative); /*store return adress in stack frame info block*/
-                               i386_mov_imm_membase((s4) m, REG_ITMP3, offmethodnative); /*store methodpointer in stack frame info block*/
-                               i386_mov_imm_membase(1111,REG_ITMP3,offaddrreturnfromnative);
-#endif
-#endif
-                       }
                        /* copy arguments to registers or stack location                  */
 
                        for (; --s3 >= 0; src = src->prev) {
@@ -4734,12 +4714,18 @@ gen_method: {
 
                        i386_push_reg(REG_ITMP2_XPC);
 
+
+                       PREPARE_NATIVE_STACKINFO
+
                        i386_alu_imm_reg(I386_SUB, 1 * 4, REG_SP);
                        i386_mov_imm_membase((s4) string_java_lang_ClassCastException, REG_SP, 0 * 4);
                        i386_mov_imm_reg((s4) new_exception, REG_ITMP1);
                        i386_call_reg(REG_ITMP1);    /* return value is REG_ITMP1_XPTR */
                        i386_alu_imm_reg(I386_ADD, 1 * 4, REG_SP);
 
+
+                       REMOVE_NATIVE_STACKINFO
+
                        i386_pop_reg(REG_ITMP2_XPC);
 
                        i386_mov_imm_reg((s4) asm_handle_exception, REG_ITMP3);
@@ -4824,7 +4810,13 @@ gen_method: {
                        xcodeptr = mcodeptr;
 
                        i386_push_reg(REG_ITMP2_XPC);
+
                        PREPARE_NATIVE_STACKINFO
+
+                                i386_mov_imm_reg((s4) codegen_general_stubcalled,REG_ITMP1);
+                                i386_call_reg(REG_ITMP1);                
+
+
 #if defined(USE_THREADS) && defined(NATIVE_THREADS)
                        i386_mov_imm_reg((s4) &builtin_get_exceptionptrptr, REG_ITMP1);
                        i386_call_reg(REG_ITMP1);
@@ -4836,7 +4828,39 @@ gen_method: {
                        i386_mov_membase_reg(REG_ITMP3, 0, REG_ITMP1_XPTR);
                        i386_mov_imm_membase(0, REG_ITMP3, 0);
 #endif
+                       i386_push_imm(0);
+                       i386_push_reg(REG_ITMP1_XPTR);
+
+/*get the fillInStackTrace Method ID. I simulate a native call here, because I do not want to mess around with the
+java stack at this point*/
+                       i386_mov_membase_reg(REG_ITMP1_XPTR, OFFSET(java_objectheader, vftbl), REG_ITMP3);
+                       i386_mov_membase_reg(REG_ITMP3, OFFSET(vftbl,class), REG_ITMP1);
+                       i386_push_imm(utf_fillInStackTrace_desc);
+                       i386_push_imm(utf_fillInStackTrace_name);
+                       i386_push_reg(REG_ITMP1);
+                       i386_mov_imm_reg((s4) class_resolvemethod, REG_ITMP3);
+                       i386_call_reg(REG_ITMP3);
+/*cleanup parameters of class_resolvemethod*/
+                       i386_alu_imm_reg(I386_ADD,3*4 /*class reference + 2x string reference*/,REG_SP);
+/*prepare call to asm_calljavafunction2 */                     
+                       i386_push_imm(0);
+                       i386_push_imm(TYPE_ADR); /* --> call block (TYPE,Exceptionptr), each 8 byte  (make this dynamic) (JOWENN)*/
+                       i386_push_reg(REG_SP);
+                       i386_push_imm(sizeof(jni_callblock));
+                       i386_push_imm(1);
+                       i386_push_reg(REG_RESULT);
+                       
+                       i386_mov_imm_reg((s4) asm_calljavafunction2, REG_ITMP3);
+                       i386_call_reg(REG_ITMP3);
+
+                       /* check exceptionptr + fail (JOWENN)*/                 
+
+                       i386_alu_imm_reg(I386_ADD,6*4,REG_SP);
+
+                       i386_pop_reg(REG_ITMP1_XPTR);
+                       i386_pop_reg(REG_ITMP3); /* just remove the no longer needed 0 from the stack*/
                        REMOVE_NATIVE_STACKINFO
+
                        i386_pop_reg(REG_ITMP2_XPC);
 
                        i386_mov_imm_reg((s4) asm_handle_exception, REG_ITMP3);
index 04eabc763c829e8e473a8feb39a9c10810d1cda4..27a93a70cbec0f961a72e29b0b65af1d8496a727 100644 (file)
--- a/jit/jit.c
+++ b/jit/jit.c
@@ -29,7 +29,7 @@
 
    Changes: Edwin Steiner
 
-   $Id: jit.c 1093 2004-05-27 15:49:43Z twisti $
+   $Id: jit.c 1112 2004-05-31 15:47:20Z jowenn $
 
 */
 
@@ -794,8 +794,7 @@ int jcommandsize[256] = {
        1,
 #define ICMD_CHECKEXCEPTION   203
        1, /* unused */
-
-             1,1,1,1,1,1,1,            /* unused */
+       1,1,1,1,1,1,1,            /* unused */
        1,1,1,1,1,1,1,1,1,1,
        1,1,1,1,1,1,1,1,1,1,
        1,1,1,1,1,1,1,1,1,1,
@@ -1008,9 +1007,8 @@ char *icmd_names[256] = {
        "UNDEF200     ", /* GOTO_W      200 */
        "UNDEF201     ", /* JSR_W       201 */
        "UNDEF202     ", /* BREAKPOINT  202 */
-       "CHECKEXCEPTION", /* UNDEF204    203 */
-
-                                        "UNDEF204","UNDEF205",
+       "CHECKEXCEPTION", /* UNDEF203    203 */
+                                       "UNDEF204", "UNDEF205",
        "UNDEF206","UNDEF207","UNDEF208","UNDEF209","UNDEF210",
        "UNDEF","UNDEF","UNDEF","UNDEF","UNDEF",
        "UNDEF216","UNDEF217","UNDEF218","UNDEF219","UNDEF220",
@@ -1233,8 +1231,7 @@ char *opcode_names[256] = {
        "JSR_W        ", /* JSR_W       201 */
        "BREAKPOINT   ", /* BREAKPOINT  202 */
        "CHECKEXCEPTION", /* UNDEF203    203 */
-
-                                        "UNDEF204","UNDEF205",
+                                        "UNDEF204","UNDEF205",
        "UNDEF206","UNDEF207","UNDEF208","UNDEF209","UNDEF210",
        "UNDEF","UNDEF","UNDEF","UNDEF","UNDEF",
        "UNDEF216","UNDEF217","UNDEF218","UNDEF219","UNDEF220",
index 70aca732c3b71d20ee666ca726bc7fd559333675..e33fd85bc37c2818c5fa97dec1e93092a3d229e2 100644 (file)
@@ -28,7 +28,7 @@
 
    Changes: Edwin Steiner
 
-   $Id: stack.c 1095 2004-05-27 15:54:42Z twisti $
+   $Id: stack.c 1112 2004-05-31 15:47:20Z jowenn $
 
 */
 
@@ -2773,7 +2773,7 @@ void show_icmd(instruction *iptr,bool deadcode)
                }
                break;
        }
-       printf(" Line number: %d, class:",iptr->line);
+       printf(" Line number: %d, method:",iptr->line);
        utf_display(iptr->method->class->name);
        printf(".");
        utf_display(iptr->method->name);
diff --git a/jni.c b/jni.c
index da6435e187e303df980c58ebc0800c52a22693bb..360ac4d9b304c6301de7271de012b3c835a0ffeb 100644 (file)
--- a/jni.c
+++ b/jni.c
@@ -28,7 +28,7 @@
 
    Changes: Joseph Wenninger
 
-   $Id: jni.c 1067 2004-05-18 10:25:51Z stefan $
+   $Id: jni.c 1112 2004-05-31 15:47:20Z jowenn $
 
 */
 
@@ -506,6 +506,7 @@ jmethodID get_virtual(jobject obj,jmethodID methodID) {
 
 jmethodID get_nonvirtual(jclass clazz,jmethodID methodID) {
        if (clazz==methodID->class) return methodID;
+/*class_resolvemethod -> classfindmethod? (JOWENN)*/
        return class_resolvemethod (clazz, methodID->name, methodID->descriptor);
 }
 
@@ -1167,7 +1168,10 @@ jmethodID GetMethodID(JNIEnv* env, jclass clazz, const char *name, const char *s
        );
 
        if (!m) *exceptionptr = new_exception(string_java_lang_NoSuchMethodError);
-
+       else if (m->flags & ACC_STATIC)   {
+               m=0;
+               *exceptionptr = new_exception(string_java_lang_NoSuchMethodError);
+       }
        return m;
 }
 
@@ -1912,6 +1916,10 @@ jmethodID GetStaticMethodID(JNIEnv *env, jclass clazz, const char *name, const c
                                                        utf_new_char((char *) sig));
 
        if (!m) *exceptionptr = new_exception(string_java_lang_NoSuchMethodError);
+       else if (!(m->flags & ACC_STATIC))   {
+               m=0;
+               *exceptionptr = new_exception(string_java_lang_NoSuchMethodError);
+       }
 
        return m;
 }
index 3864f29af0818707d2788f054e8dfc44efb89f30..4b094d28db29760a2f64246ee2d96b93e020d71d 100644 (file)
--- a/loader.c
+++ b/loader.c
@@ -30,7 +30,7 @@
             Mark Probst
                        Edwin Steiner
 
-   $Id: loader.c 1110 2004-05-28 21:45:51Z jowenn $
+   $Id: loader.c 1112 2004-05-31 15:47:20Z jowenn $
 
 */
 
@@ -96,6 +96,8 @@ static utf *utf_initialize;
 static utf *utf_initializedesc;
 static utf *utf_java_lang_Object;   /* java/lang/Object                       */
 
+utf *utf_fillInStackTrace_name;
+utf *utf_fillInStackTrace_desc;
 
 utf* clinit_desc(){
        return utf_fidesc;
@@ -1832,7 +1834,7 @@ classinfo *class_load(classinfo *c)
                *exceptionptr =
                        new_exception_utfmessage(string_java_lang_NoClassDefFoundError,
                                                                         c->name);
-
+/*             log_text("Leaving class_load with NoClassDefFoundError");*/
 #if defined(USE_THREADS)
 #if defined(NATIVE_THREADS)
                tables_unlock();
@@ -3155,12 +3157,20 @@ methodinfo *class_resolvemethod_approx(classinfo *c, utf *name, utf *desc)
 
 methodinfo *class_resolvemethod(classinfo *c, utf *name, utf *desc)
 {
+       /*log_text("Trying to resolve a method");
+       utf_display(c->name);
+       utf_display(name);
+       utf_display(desc);*/
+
        while (c) {
+               /*log_text("Looking in:");
+               utf_display(c->name);*/
                methodinfo *m = class_findmethod(c, name, desc);
                if (m) return m;
                /* search superclass */
                c = c->super;
        }
+       /*log_text("method not found:");*/
 
        return NULL;
 }
@@ -4011,6 +4021,8 @@ void loader_init(u1 *stackbottom)
        utf_vmclass         = utf_new_char("java/lang/VMClass");
        utf_java_lang_Object= utf_new_char("java/lang/Object");
        array_packagename   = utf_new_char("<the array package>");
+       utf_fillInStackTrace_name = utf_new_char("fillInStackTrace");
+       utf_fillInStackTrace_desc = utf_new_char("()Ljava/lang/Throwable;");
 
        /* create some important classes */
        /* These classes have to be created now because the classinfo
index 32e0289a05c634f75e16e8355101cc15d562f7cc..ac745609894dc46e40168a61989eb0ed1856c9c8 100644 (file)
--- a/loader.h
+++ b/loader.h
@@ -26,7 +26,7 @@
 
    Authors: Reinhard Grafl
 
-   $Id: loader.h 1088 2004-05-26 21:32:34Z twisti $
+   $Id: loader.h 1112 2004-05-31 15:47:20Z jowenn $
 */
 
 
@@ -63,7 +63,8 @@ extern classinfo *class_java_lang_Object;
 extern classinfo *class_java_lang_String;
 extern classinfo *class_java_lang_Cloneable;
 extern classinfo *class_java_io_Serializable;
-
+extern utf *utf_fillInStackTrace_name;
+extern utf *utf_fillInStackTrace_desc;
 
 /* pseudo classes for the type checker ****************************************/
 
index ccf068e762c0a81887abc6388293fdc4e8b18d25..9f5d2a4e83e1966b9c533313e87c416da580e9b6 100644 (file)
@@ -14,7 +14,7 @@ JNIEXPORT void JNICALL Java_java_lang_JOWENNTest1_f1 (JNIEnv *env , jclass clazz
 
        printf("JOWENNTest1_nat:%ld\n",par1);
 
-        mid = (*env)->GetMethodID(env, clazz, "f1a", "(I)V");
+        mid = (*env)->GetStaticMethodID(env, clazz, "f1a", "(I)V");
 
         (*env)->CallStaticVoidMethod(env, clazz, mid,par1);
 
@@ -29,7 +29,7 @@ JNIEXPORT void JNICALL Java_java_lang_JOWENNTest1_f2 (JNIEnv *env , jclass clazz
        jmethodID mid;
 
        printf("JOWENNTest1_nat:%lld\n",par1);
-        mid = (*env)->GetMethodID(env, clazz, "f2a", "(J)V");
+        mid = (*env)->GetStaticMethodID(env, clazz, "f2a", "(J)V");
 
         (*env)->CallStaticVoidMethod(env, clazz, mid,par1);
 
@@ -44,7 +44,7 @@ JNIEXPORT void JNICALL Java_java_lang_JOWENNTest1_f3 (JNIEnv *env , jclass clazz
        jmethodID mid;
 
        printf("JOWENNTest1_nat:%g\n",par1);
-        mid = (*env)->GetMethodID(env, clazz, "f3a", "(F)V");
+        mid = (*env)->GetStaticMethodID(env, clazz, "f3a", "(F)V");
 
        if (mid==0) {printf("ERROR: f3a: (F)V not found\n"); exit(1);}
 
@@ -62,7 +62,7 @@ JNIEXPORT void JNICALL Java_java_lang_JOWENNTest1_f4 (JNIEnv *env , jclass clazz
        jmethodID mid;
 
        printf("JOWENNTest1_nat:%g\n",par1);
-        mid = (*env)->GetMethodID(env, clazz, "f4a", "(D)V");
+        mid = (*env)->GetStaticMethodID(env, clazz, "f4a", "(D)V");
 
         (*env)->CallStaticVoidMethod(env, clazz, mid,par1);
 
@@ -78,7 +78,7 @@ JNIEXPORT void JNICALL Java_java_lang_JOWENNTest1_f5 (JNIEnv *env , jclass clazz
        jmethodID mid;
 
        printf("JOWENNTest1_nat_f5:%d\n",par1);
-        mid = (*env)->GetMethodID(env, clazz, "f5a", "(I)V");
+        mid = (*env)->GetStaticMethodID(env, clazz, "f5a", "(I)V");
 
         (*env)->CallStaticVoidMethod(env, clazz, mid,par1);
 
@@ -123,7 +123,7 @@ JNIEXPORT void JNICALL Java_java_lang_JOWENNTest1_f7 (JNIEnv *env ,  struct java
 
         (*env)->CallVoidMethod(env, this, mid,1,2,3);
 
-        mid = (*env)->GetMethodID(env, this->header.vftbl->class, "f7b", "(III)V");
+        mid = (*env)->GetStaticMethodID(env, this->header.vftbl->class, "f7b", "(III)V");
 
         (*env)->CallStaticVoidMethod(env, this, mid,1,2,3);
 
@@ -142,7 +142,7 @@ JNIEXPORT void JNICALL Java_java_lang_JOWENNTest1_f8 (JNIEnv *env ,  struct java
 
        printf("JOWENNTest1_nat_f8\n");
 //     class_showmethods(this->header.vftbl->class);
-        mid = (*env)->GetMethodID(env, this->header.vftbl->class, "f7a", "(III)V");
+        mid = (*env)->GetStaticMethodID(env, this->header.vftbl->class, "f7a", "(III)V");
 
         (*env)->CallStaticVoidMethod(env, this, mid,1,2,3);
        if ((*env)->ExceptionOccurred(env)) {
@@ -162,7 +162,7 @@ JNIEXPORT void JNICALL Java_java_lang_JOWENNTest1_f9 (JNIEnv *env ,  struct java
 
        printf("JOWENNTest1_nat_f9\n");
 //     class_showmethods(this->header.vftbl->class);
-        mid = (*env)->GetMethodID(env, this->header.vftbl->class, "f7b", "(III)V");
+        mid = (*env)->GetStaticMethodID(env, this->header.vftbl->class, "f7b", "(III)V");
 
         (*env)->CallVoidMethod(env, this, mid,1,2,3);
        if ((*env)->ExceptionOccurred(env)) {
index 3cbed421ebc512173623e5482c47f8f659c140de..88a255e53ced96516c05fa1bcb3c3ab7c676e6f7 100644 (file)
@@ -26,7 +26,7 @@
 
    Authors: Joseph Wenninger
 
-   $Id: VMThrowable.c 1082 2004-05-26 15:04:54Z jowenn $
+   $Id: VMThrowable.c 1112 2004-05-31 15:47:20Z jowenn $
 
 */
 
@@ -106,13 +106,14 @@ java_objectarray* generateStackTraceArray(JNIEnv *env,stacktraceelement *source,
        
        
        for(resultPos=0;pos>=0;resultPos++,pos--) {
+               java_objectheader *element;
 
                if (source[pos].method==0) {
                        resultPos--;
                        continue;
                }
 
-               java_objectheader *element=builtin_new(c);
+               element=builtin_new(c);
                if (!element) {
                        panic("Memory for stack trace element could not be allocated");
                }
@@ -185,11 +186,21 @@ JNIEXPORT java_objectarray* JNICALL Java_java_lang_VMThrowable_getStackTrace(JNI
        pos--;
        pos--;
        maxpos = pos;
-       if (el[pos].method->class->name == throwable && el[pos].method->name == init) {
-               for (; pos >= 0 && el[pos].method->name == init && el[pos].method->class->name != classname; pos--);
-               pos--;
-               if (pos < 0) {
-                       log_text("Invalid stack trace for Throwable.getStackTrace()");
+       if (el[pos].method!=0) { /* if == 0 -> some builtin native */
+               if (el[pos].method->class->name == throwable && el[pos].method->name == init) {
+                       for (; pos >= 0 && el[pos].method->name == init && el[pos].method->class->name != classname; pos--) {
+/*                             log_text("ignoring:");
+                               utf_display(el[pos].method->name);
+                               log_text("");
+                               utf_display(el[pos].method->class->name);
+                               log_text("");*/
+
+                       };
+                       pos--;
+                       if (pos < 0) {
+                               log_text("Invalid stack trace for Throwable.getStackTrace()");
+
+                       }
                }
        }
        
index 8d10881f2100d5e1635806499c038de10dffb9fc..57ecd398610048788181fcbd29fed866d712570e 100644 (file)
@@ -11,7 +11,7 @@
 JNIEXPORT void JNICALL Java_classcontextnativeTest_a(JNIEnv *env, jclass clazz){
        jmethodID mid;
         printf("classcontextnativeTest_nat: a()\n");
-        mid = (*env)->GetMethodID(env, clazz, "b", "()V");
+        mid = (*env)->GetStaticMethodID(env, clazz, "b", "()V");
         (*env)->CallStaticVoidMethod(env, clazz, mid);
 
 
@@ -26,7 +26,7 @@ JNIEXPORT void JNICALL Java_classcontextnativeTest_a(JNIEnv *env, jclass clazz){
 JNIEXPORT void JNICALL Java_classcontextnativeTest_k(JNIEnv *env, jclass clazz){
        jmethodID mid;
         printf("classcontextnativeTest_nat: k()\n");
-        mid = (*env)->GetMethodID(env, clazz, "l", "()V");
+        mid = (*env)->GetStaticMethodID(env, clazz, "l", "()V");
         (*env)->CallStaticVoidMethod(env, clazz, mid);
 }
 
@@ -38,7 +38,7 @@ JNIEXPORT void JNICALL Java_classcontextnativeTest_k(JNIEnv *env, jclass clazz){
 JNIEXPORT void JNICALL Java_classcontextnativeTest_y(JNIEnv *env, jclass clazz) {
        jmethodID mid;
         printf("classcontextnativeTest_nat: y()\n");
-        mid = (*env)->GetMethodID(env, clazz, "z", "()V");
+        mid = (*env)->GetStaticMethodID(env, clazz, "z", "()V");
         (*env)->CallStaticVoidMethod(env, clazz, mid);
 }
 
index a20bacf87906e37996c1992a2e9005c117726abf..01a6160ea945d39bcbc25418fd179bea296170f7 100644 (file)
--- a/native.c
+++ b/native.c
@@ -31,7 +31,7 @@
    The .hh files created with the header file generator are all
    included here as are the C functions implementing these methods.
 
-   $Id: native.c 1106 2004-05-28 10:25:55Z twisti $
+   $Id: native.c 1112 2004-05-31 15:47:20Z jowenn $
 
 */
 
@@ -526,18 +526,26 @@ void throw_cacao_exception_exit(char *exception, char *message)
 }
 
 
+#define CREATENEW_EXCEPTION(ex) \
+       java_objectheader *newEx; \
+       java_objectheader *oldexception=*exceptionptr;\
+       *exceptionptr=0;\
+       newEx=ex;\
+       *exceptionptr=oldexception;\
+       return newEx;
+
 java_objectheader *new_exception(char *classname)
 {
        classinfo *c = class_new(utf_new_char(classname));
 
-       return native_new_and_init(c);
+       CREATENEW_EXCEPTION(native_new_and_init(c));
 }
 
 java_objectheader *new_exception_message(char *classname, char *message)
 {
        classinfo *c = class_new(utf_new_char(classname));
 
-       return native_new_and_init_string(c, javastring_new_char(message));
+       CREATENEW_EXCEPTION(native_new_and_init_string(c, javastring_new_char(message)));
 }
 
 
@@ -545,7 +553,7 @@ java_objectheader *new_exception_throwable(char *classname, java_lang_Throwable
 {
        classinfo *c = class_new(utf_new_char(classname));
 
-       return native_new_and_init_throwable(c, throwable);
+       CREATENEW_EXCEPTION(native_new_and_init_throwable(c, throwable));
 }
 
 
@@ -553,7 +561,7 @@ java_objectheader *new_exception_utfmessage(char *classname, utf *message)
 {
        classinfo *c = class_new(utf_new_char(classname));
 
-       return native_new_and_init_string(c, javastring_new(message));
+       CREATENEW_EXCEPTION(native_new_and_init_string(c, javastring_new(message)));
 }
 
 
@@ -561,7 +569,7 @@ java_objectheader *new_exception_javastring(char *classname, java_lang_String *m
 {
        classinfo *c = class_new(utf_new_char(classname));
 
-       return native_new_and_init_string(c, message);
+       CREATENEW_EXCEPTION(native_new_and_init_string(c, message));
 }
 
 
@@ -569,7 +577,7 @@ java_objectheader *new_exception_int(char *classname, s4 i)
 {
        classinfo *c = class_new(utf_new_char(classname));
 
-       return native_new_and_init_int(c, i);
+       CREATENEW_EXCEPTION(native_new_and_init_int(c, i));
 }
 
 
index d455b5c2937861f2ab8bec4fa313685944905002..07d8a05c44474fa93cac5cdbbb3435d637aaa2f9 100644 (file)
@@ -29,7 +29,7 @@
    Changes: Mark Probst
             Philipp Tomsich
 
-   $Id: headers.c 1097 2004-05-27 15:58:34Z twisti $
+   $Id: headers.c 1112 2004-05-31 15:47:20Z jowenn $
 
 */
 
@@ -693,6 +693,7 @@ int main(int argc, char **argv)
        fprintf(file, "#define offobjarrdata  %3d\n\n", (int) OFFSET(java_objectarray, data[0]));
        fprintf(file, "#define offbaseval     %3d\n", (int) OFFSET(vftbl, baseval));
        fprintf(file, "#define offdiffval     %3d\n\n", (int) OFFSET(vftbl, diffval));
+       fprintf(file, "#define offclass     %3d\n\n", (int) OFFSET(vftbl, class));
 
        fprintf(file, "#define offclassvftbl  %3d\n", (int) OFFSET(classinfo, vftbl));
        fprintf(file, "#define offclassinit   %3d\n", (int) OFFSET(classinfo, initialized));
index da6435e187e303df980c58ebc0800c52a22693bb..360ac4d9b304c6301de7271de012b3c835a0ffeb 100644 (file)
@@ -28,7 +28,7 @@
 
    Changes: Joseph Wenninger
 
-   $Id: jni.c 1067 2004-05-18 10:25:51Z stefan $
+   $Id: jni.c 1112 2004-05-31 15:47:20Z jowenn $
 
 */
 
@@ -506,6 +506,7 @@ jmethodID get_virtual(jobject obj,jmethodID methodID) {
 
 jmethodID get_nonvirtual(jclass clazz,jmethodID methodID) {
        if (clazz==methodID->class) return methodID;
+/*class_resolvemethod -> classfindmethod? (JOWENN)*/
        return class_resolvemethod (clazz, methodID->name, methodID->descriptor);
 }
 
@@ -1167,7 +1168,10 @@ jmethodID GetMethodID(JNIEnv* env, jclass clazz, const char *name, const char *s
        );
 
        if (!m) *exceptionptr = new_exception(string_java_lang_NoSuchMethodError);
-
+       else if (m->flags & ACC_STATIC)   {
+               m=0;
+               *exceptionptr = new_exception(string_java_lang_NoSuchMethodError);
+       }
        return m;
 }
 
@@ -1912,6 +1916,10 @@ jmethodID GetStaticMethodID(JNIEnv *env, jclass clazz, const char *name, const c
                                                        utf_new_char((char *) sig));
 
        if (!m) *exceptionptr = new_exception(string_java_lang_NoSuchMethodError);
+       else if (!(m->flags & ACC_STATIC))   {
+               m=0;
+               *exceptionptr = new_exception(string_java_lang_NoSuchMethodError);
+       }
 
        return m;
 }
index a20bacf87906e37996c1992a2e9005c117726abf..01a6160ea945d39bcbc25418fd179bea296170f7 100644 (file)
@@ -31,7 +31,7 @@
    The .hh files created with the header file generator are all
    included here as are the C functions implementing these methods.
 
-   $Id: native.c 1106 2004-05-28 10:25:55Z twisti $
+   $Id: native.c 1112 2004-05-31 15:47:20Z jowenn $
 
 */
 
@@ -526,18 +526,26 @@ void throw_cacao_exception_exit(char *exception, char *message)
 }
 
 
+#define CREATENEW_EXCEPTION(ex) \
+       java_objectheader *newEx; \
+       java_objectheader *oldexception=*exceptionptr;\
+       *exceptionptr=0;\
+       newEx=ex;\
+       *exceptionptr=oldexception;\
+       return newEx;
+
 java_objectheader *new_exception(char *classname)
 {
        classinfo *c = class_new(utf_new_char(classname));
 
-       return native_new_and_init(c);
+       CREATENEW_EXCEPTION(native_new_and_init(c));
 }
 
 java_objectheader *new_exception_message(char *classname, char *message)
 {
        classinfo *c = class_new(utf_new_char(classname));
 
-       return native_new_and_init_string(c, javastring_new_char(message));
+       CREATENEW_EXCEPTION(native_new_and_init_string(c, javastring_new_char(message)));
 }
 
 
@@ -545,7 +553,7 @@ java_objectheader *new_exception_throwable(char *classname, java_lang_Throwable
 {
        classinfo *c = class_new(utf_new_char(classname));
 
-       return native_new_and_init_throwable(c, throwable);
+       CREATENEW_EXCEPTION(native_new_and_init_throwable(c, throwable));
 }
 
 
@@ -553,7 +561,7 @@ java_objectheader *new_exception_utfmessage(char *classname, utf *message)
 {
        classinfo *c = class_new(utf_new_char(classname));
 
-       return native_new_and_init_string(c, javastring_new(message));
+       CREATENEW_EXCEPTION(native_new_and_init_string(c, javastring_new(message)));
 }
 
 
@@ -561,7 +569,7 @@ java_objectheader *new_exception_javastring(char *classname, java_lang_String *m
 {
        classinfo *c = class_new(utf_new_char(classname));
 
-       return native_new_and_init_string(c, message);
+       CREATENEW_EXCEPTION(native_new_and_init_string(c, message));
 }
 
 
@@ -569,7 +577,7 @@ java_objectheader *new_exception_int(char *classname, s4 i)
 {
        classinfo *c = class_new(utf_new_char(classname));
 
-       return native_new_and_init_int(c, i);
+       CREATENEW_EXCEPTION(native_new_and_init_int(c, i));
 }
 
 
index 3cbed421ebc512173623e5482c47f8f659c140de..88a255e53ced96516c05fa1bcb3c3ab7c676e6f7 100644 (file)
@@ -26,7 +26,7 @@
 
    Authors: Joseph Wenninger
 
-   $Id: VMThrowable.c 1082 2004-05-26 15:04:54Z jowenn $
+   $Id: VMThrowable.c 1112 2004-05-31 15:47:20Z jowenn $
 
 */
 
@@ -106,13 +106,14 @@ java_objectarray* generateStackTraceArray(JNIEnv *env,stacktraceelement *source,
        
        
        for(resultPos=0;pos>=0;resultPos++,pos--) {
+               java_objectheader *element;
 
                if (source[pos].method==0) {
                        resultPos--;
                        continue;
                }
 
-               java_objectheader *element=builtin_new(c);
+               element=builtin_new(c);
                if (!element) {
                        panic("Memory for stack trace element could not be allocated");
                }
@@ -185,11 +186,21 @@ JNIEXPORT java_objectarray* JNICALL Java_java_lang_VMThrowable_getStackTrace(JNI
        pos--;
        pos--;
        maxpos = pos;
-       if (el[pos].method->class->name == throwable && el[pos].method->name == init) {
-               for (; pos >= 0 && el[pos].method->name == init && el[pos].method->class->name != classname; pos--);
-               pos--;
-               if (pos < 0) {
-                       log_text("Invalid stack trace for Throwable.getStackTrace()");
+       if (el[pos].method!=0) { /* if == 0 -> some builtin native */
+               if (el[pos].method->class->name == throwable && el[pos].method->name == init) {
+                       for (; pos >= 0 && el[pos].method->name == init && el[pos].method->class->name != classname; pos--) {
+/*                             log_text("ignoring:");
+                               utf_display(el[pos].method->name);
+                               log_text("");
+                               utf_display(el[pos].method->class->name);
+                               log_text("");*/
+
+                       };
+                       pos--;
+                       if (pos < 0) {
+                               log_text("Invalid stack trace for Throwable.getStackTrace()");
+
+                       }
                }
        }
        
index 12addc485be777300492bbdd1a08acd7c5d7ca3e..017eb1aea9a5dbe232481ecc23a559ac343780c2 100644 (file)
@@ -34,7 +34,7 @@
    calls instead of machine instructions, using the C calling
    convention.
 
-   $Id: builtin.c 1085 2004-05-26 18:52:37Z twisti $
+   $Id: builtin.c 1112 2004-05-31 15:47:20Z jowenn $
 
 */
 
@@ -1812,7 +1812,7 @@ stacktraceelement *builtin_stacktrace_copy(stacktraceelement **el,stacktraceelem
        size_t s;
        s=(end-begin);
        /*printf ("begin: %p, end: %p, diff: %ld, size :%ld\n",begin,end,s,s*sizeof(stacktraceelement));*/
-       *el=GCNEW(stacktraceelement,s+1);
+       *el=MNEW(stacktraceelement,s+1); /*GC*/
        memcpy(*el,begin,(end-begin)*sizeof(stacktraceelement));
        (*el)[s].method=0;
 #warning change this if line numbers bigger than u2 are allowed, the currently supported class file format does no allow that
index 8a42b80f8aa8a19b9be4327a6b283d30a9c3dd38..6b5f42399ba87141c1bcc0ad08a3241ff389e178 100644 (file)
@@ -31,7 +31,7 @@
             Philipp Tomsich
                        Edwin Steiner
 
-   $Id: global.h 1082 2004-05-26 15:04:54Z jowenn $
+   $Id: global.h 1112 2004-05-31 15:47:20Z jowenn $
 
 */
 
@@ -322,7 +322,7 @@ typedef struct stacktraceelement stacktraceelement;
 /* data structure for calls from c code to java methods */
 
 struct jni_callblock {
-       u1 itemtype;
+       u8 itemtype;
        u8 item;
 };
 
index d6a205dd4446e5fe7600b18307d9e334d4723db6..a8ff334c987701e0a1196daccb599792f5cde9b3 100644 (file)
@@ -29,7 +29,7 @@
 
    Changes: Christian Thalinger
 
-   $Id: asmpart.h 1082 2004-05-26 15:04:54Z jowenn $
+   $Id: asmpart.h 1112 2004-05-31 15:47:20Z jowenn $
 
 */
 
@@ -84,7 +84,7 @@ void asm_handle_nat_exception();
 void asm_check_clinit();
 
 void asm_handle_builtin_exception(classinfo *);
-void asm_throw_and_handle_hardware_nullpointer_exception();
+void asm_throw_and_handle_exception();
 void asm_throw_and_handle_hardware_arithmetic_exception();
 
 java_objectarray* Java_java_lang_VMSecurityManager_getClassContext(JNIEnv *env, jclass clazz);
index 7ca7b29f483b2bcd8ba99c5752b9bbe29704bc5c..de678d16fbffa29285bcd755e8472dd2a58a2dcd 100644 (file)
@@ -48,7 +48,7 @@
    memory. All functions writing values into the data area return the offset
    relative the begin of the code area (start of procedure).   
 
-   $Id: codegen.inc 1099 2004-05-27 16:06:14Z twisti $
+   $Id: codegen.inc 1112 2004-05-31 15:47:20Z jowenn $
 
 */
 
@@ -501,6 +501,22 @@ static int methodtree_comparator(const void *pc, const void *element,
 }
 
 
+#if 0
+void *codegen_findmethod1(void *pc)
+{
+       void * retVal=findmethod(pc);
+       methodinfo **ma=(methodinfo**)retVal;
+       methodinfo *m=ma[-1];
+       if (m)
+               if (m->name)
+                       utf_display(m->name);
+               else 
+                       log_text("No Name");
+       else log_text("No methodinfo");
+       return retVal;
+}
+#endif
+
 void *codegen_findmethod(void *pc)
 {
 #if 1
index a534e6da3722178c54a9cf4a29624c8e4beed1d0..7aff7a23e1e4317207a7fad50819b50d4ab56ea0 100644 (file)
@@ -29,7 +29,7 @@
             Reinhard Grafl
             Christian Thalinger
 
-   $Id: asmpart.S 1111 2004-05-29 07:51:40Z jowenn $
+   $Id: asmpart.S 1112 2004-05-31 15:47:20Z jowenn $
 
 */
 
        .globl builtin_trace_exception
        .globl class_java_lang_Object
        .globl codegen_findmethod
+/*     .globl codegen_findmethod1*/
        .globl builtin_asm_createclasscontextarray
        .globl builtin_asm_getclassloader
        .globl callgetexceptionptrptr
-       .globl asm_throw_and_handle_hardware_nullpointer_exception
+       .globl asm_throw_and_handle_exception
        .globl asm_throw_and_handle_hardware_arithmetic_exception
 
 
@@ -394,6 +395,44 @@ L_exception:
        pop     %ecx                /* delete return address                      */
        sub     $2,%ecx             /* faulting address is return adress - 2      */
 
+L_refillinStacktrace:
+       push %ecx               /* store fault adress */
+       push %eax               /* temporarily save exception pointer*/
+       call builtin_asm_get_stackframeinfo
+       push %eax       /* save location of thread specific stack info head pointer */
+       mov (%eax),%ecx /* save old value of pointer*/
+       push %ecx
+       mov %esp,(%eax) /*store pointer to this structure*/
+       mov 8(%esp),%eax  /* get the exception pointer again*/
+       movl $0,8(%esp) /*mark this block as native*/
+       push $0 /*used for the jni_callblock structure*/
+       push %eax /*save eax for later */
+       /* get fillInStackTrace method*/
+       push utf_fillInStackTrace_desc
+       push utf_fillInStackTrace_name
+       mov offobjvftbl(%eax),%ecx
+       mov offclass(%ecx),%eax
+       push %eax
+       call class_resolvemethod
+       add $12,%esp
+       push $0
+       push $4 /*TYPE_ADR*/
+       push %esp
+       push $sizejniblock
+       push $1
+       push %eax
+       call asm_calljavafunction2
+       add $24,%esp
+
+       /*remove native stack info */
+       mov 8(%esp),%ecx
+       mov 12(%esp),%eax
+       mov %ecx,(%eax)
+       mov (%esp),%eax
+       add $20,%esp
+       pop %ecx
+
+       
        jmp     asm_handle_exception
 
 
@@ -432,7 +471,7 @@ asm_handle_exception_loop:
                push    %eax                                            /* save exception pointer         */
                push    %ecx                        /* save exception pc              */
 
-       call    codegen_findmethod          /* get the data segment ptr           */
+               call    codegen_findmethod          /* get the data segment ptr           */
                mov     %eax,%edx
                        
                mov     -4(%ebp),%eax
@@ -709,6 +748,12 @@ asm_builtin_monitorenter:
        jmp             builtin_monitorenter        /* else call builtin_monitorenter     */
 
 nb_monitorenter:
+        mov string_java_lang_NullPointerException,%eax
+        pop %ecx
+        sub $2,%ecx
+        jmp asm_throw_and_handle_exception
+
+#if 0
        push    string_java_lang_NullPointerException
        call    new_exception
        add     $(1*4),%esp
@@ -716,7 +761,7 @@ nb_monitorenter:
        pop     %ecx                        /* delete return address              */
        sub     $2,%ecx                     /* faulting address is return adress - 2 */
        jmp     asm_handle_exception
-               
+#endif         
 
 /********************* function asm_builtin_monitorexit ************************
 *                                                                              *
@@ -738,6 +783,12 @@ asm_builtin_monitorexit:
     ret
 
 nb_monitorexit:
+        mov string_java_lang_NullPointerException,%eax
+        pop %ecx
+        sub $2,%ecx
+        jmp asm_throw_and_handle_exception
+
+#if 0
        push    string_java_lang_NullPointerException
        call    new_exception
        add     $(1*4),%esp
@@ -745,7 +796,7 @@ nb_monitorexit:
        pop     %ecx                    /* delete return address              */
        sub     $2,%ecx                 /* faulting address is return adress - 2 */
        jmp     asm_handle_exception
-
+#endif
 
 /************************ function asm_builtin_ldiv ****************************
 *                                                                              *
@@ -762,6 +813,10 @@ asm_builtin_ldiv:
        jmp     builtin_ldiv
 
 nb_ldiv:
+       pop %ecx
+       sub $2,%ecx
+       jmp asm_throw_and_handle_hardware_arithmetic_exception
+#if 0
        push    string_java_lang_ArithmeticException_message
        push    string_java_lang_ArithmeticException
        call    new_exception_message
@@ -770,7 +825,7 @@ nb_ldiv:
        pop     %ecx                        /* delete return address              */
        sub     $2,%ecx                     /* faulting address is return adress - 2 */
        jmp     asm_handle_exception
-                               
+#endif                         
 
 /************************ function asm_builtin_lrem ****************************
 *                                                                              *
@@ -787,6 +842,10 @@ asm_builtin_lrem:
        jmp     builtin_lrem
 
 nb_lrem:
+       pop %ecx
+       sub $2,%ecx
+       jmp asm_throw_and_handle_hardware_arithmetic_exception
+#if 0
        push    string_java_lang_ArithmeticException_message
        push    string_java_lang_ArithmeticException
        call    new_exception_message
@@ -795,7 +854,7 @@ nb_lrem:
        pop     %ecx                        /* delete return address              */
        sub     $2,%ecx                     /* faulting address is return adress - 2 */
        jmp     asm_handle_exception
-               
+#endif         
 
 /************************ function asm_builtin_x2x *****************************
 *                                                                              *
@@ -857,6 +916,12 @@ asm_builtin_checkarraycast:
        ret
 
 nb_carray_throw:
+       add $8,%esp
+       mov string_java_lang_ClassCastException,%eax
+       pop %ecx
+       sub $2,%ecx
+       jmp asm_throw_and_handle_exception
+#if 0
        push    string_java_lang_ClassCastException
        call    new_exception
        add     $(1*4),%esp
@@ -866,7 +931,7 @@ nb_carray_throw:
        pop             %ecx                        /* delete return address              */
        sub             $2,%ecx                     /* faulting address is return adress - 2 */
        jmp             asm_handle_exception
-
+#endif
                
 /******************* function asm_builtin_newarray *****************************
 *                                                                              *
@@ -931,6 +996,13 @@ asm_builtin_aastore:
        ret
 
 nb_aastore_null:
+        add $12,%esp
+        mov string_java_lang_NullPointerException,%eax
+        pop %ecx
+        sub $2,%ecx
+        jmp asm_throw_and_handle_exception
+
+#if 0
        push    string_java_lang_NullPointerException
        call    new_exception
        add     $(1*4),%esp
@@ -939,7 +1011,7 @@ nb_aastore_null:
        pop     %ecx                        /* delete return address              */
        sub     $2,%ecx                     /* faulting address is return adress - 2 */
        jmp             asm_handle_exception
-
+#endif
 nb_aastore_bound:
        push    %ecx                        /* itmp2 contains array index         */
        push    string_java_lang_ArrayIndexOutOfBoundsException
@@ -952,6 +1024,14 @@ nb_aastore_bound:
        jmp     asm_handle_exception
                
 nb_aastore_store:
+       add     $12,%esp
+
+        mov string_java_lang_ArrayStoreException,%eax
+        pop %ecx
+        sub $2,%ecx
+        jmp asm_throw_and_handle_exception
+
+#if 0
        push    string_java_lang_ArrayStoreException
        call    new_exception
        add     $(1*4),%esp
@@ -960,7 +1040,7 @@ nb_aastore_store:
        pop     %ecx                        /* delete return address              */
        sub     $2,%ecx                     /* faulting address is return adress - 2 */
        jmp     asm_handle_exception
-
+#endif
                
 /******************* function asm_builtin_arrayinstanceof **********************
 *                                                                              *
@@ -1253,10 +1333,10 @@ getClassContext_leave:
        ret
 
 
-asm_throw_and_handle_hardware_nullpointer_exception:
+asm_throw_and_handle_exception:
        sub $20,%esp /*build stack frame*/
        mov %ecx,16(%esp) /*save eip of problem */
-       
+       mov %eax,(%esp)
        movl $0,12(%esp) /*internal function -> no function description */
        call builtin_asm_get_stackframeinfo
        mov %eax,8(%esp)
@@ -1266,8 +1346,8 @@ asm_throw_and_handle_hardware_nullpointer_exception:
        add $4,%ecx
        mov %ecx,(%eax)
        
-       mov string_java_lang_NullPointerException,%eax
-       mov %eax,(%esp)
+/*     mov string_java_lang_NullPointerException,%eax
+       mov %eax,(%esp)*/
         call new_exception
        push %eax
        mov 8(%esp),%eax
index 7c3e8b2b5c1510a30fb407d8660e0edd6f4f6e93..2885f9616e07a241ac7d4c37bfc0a0310a4505ea 100644 (file)
@@ -28,7 +28,7 @@
    Authors: Andreas Krall
             Christian Thalinger
 
-   $Id: codegen.c 1102 2004-05-27 16:30:45Z twisti $
+   $Id: codegen.c 1112 2004-05-31 15:47:20Z jowenn $
 
 */
 
@@ -320,6 +320,10 @@ void codegen_stubcalled() {
        log_text("Stub has been called");
 }
 
+void codegen_general_stubcalled() {
+       log_text("general exception stub  has been called");
+}
+
 
 #if defined(USE_THREADS) && defined(NATIVE_THREADS)
 void thread_restartcriticalsection(ucontext_t *uc)
@@ -383,7 +387,8 @@ void catch_NullPointerException(int sig, siginfo_t *siginfo, void *_p)
                sigprocmask(SIG_UNBLOCK, &nsig, NULL);           /* unblock signal    */
 
                sigctx->ecx = sigctx->eip;                       /* REG_ITMP2_XPC     */
-               sigctx->eip = (u4) asm_throw_and_handle_hardware_nullpointer_exception;
+               sigctx->eax=string_java_lang_NullPointerException;
+               sigctx->eip = (u4) asm_throw_and_handle_exception;
                
                return;
 
@@ -4019,31 +4024,6 @@ gen_method: {
 
                        MCODECHECK((s3 << 1) + 64);
 
-                       if ( (iptr->opc == ICMD_BUILTIN1) ||
-                               (iptr->opc == ICMD_BUILTIN2) ||
-                               (iptr->opc == ICMD_BUILTIN3) ) {
-#if 0
-                               i386_push_reg(REG_ITMP1);
-                               i386_push_reg(REG_ITMP2);
-                               i386_push_reg(REG_ITMP3);
-
-                               i386_mov_imm_reg((s4) builtin_asm_new_stackframeinfo, REG_ITMP1);
-                               i386_call_reg(REG_ITMP1);
-
-                               i386_pop_reg(REG_ITMP3);
-                               i386_pop_reg(REG_ITMP2);
-                               i386_pop_reg(REG_ITMP1);
-
-#if 0
-                               i386_mov_membase_reg(REG_SP, 0 , REG_ITMP2); /*save return adress*/
-                               i386_mov_membase_reg(REG_RESULT, 0 , REG_ITMP3); /*get direct access to structure*/
-
-                               i386_mov_imm_membase(0x1111, REG_ITMP3, offreturnfromnative); /*store return adress in stack frame info block*/
-                               i386_mov_imm_membase((s4) m, REG_ITMP3, offmethodnative); /*store methodpointer in stack frame info block*/
-                               i386_mov_imm_membase(1111,REG_ITMP3,offaddrreturnfromnative);
-#endif
-#endif
-                       }
                        /* copy arguments to registers or stack location                  */
 
                        for (; --s3 >= 0; src = src->prev) {
@@ -4734,12 +4714,18 @@ gen_method: {
 
                        i386_push_reg(REG_ITMP2_XPC);
 
+
+                       PREPARE_NATIVE_STACKINFO
+
                        i386_alu_imm_reg(I386_SUB, 1 * 4, REG_SP);
                        i386_mov_imm_membase((s4) string_java_lang_ClassCastException, REG_SP, 0 * 4);
                        i386_mov_imm_reg((s4) new_exception, REG_ITMP1);
                        i386_call_reg(REG_ITMP1);    /* return value is REG_ITMP1_XPTR */
                        i386_alu_imm_reg(I386_ADD, 1 * 4, REG_SP);
 
+
+                       REMOVE_NATIVE_STACKINFO
+
                        i386_pop_reg(REG_ITMP2_XPC);
 
                        i386_mov_imm_reg((s4) asm_handle_exception, REG_ITMP3);
@@ -4824,7 +4810,13 @@ gen_method: {
                        xcodeptr = mcodeptr;
 
                        i386_push_reg(REG_ITMP2_XPC);
+
                        PREPARE_NATIVE_STACKINFO
+
+                                i386_mov_imm_reg((s4) codegen_general_stubcalled,REG_ITMP1);
+                                i386_call_reg(REG_ITMP1);                
+
+
 #if defined(USE_THREADS) && defined(NATIVE_THREADS)
                        i386_mov_imm_reg((s4) &builtin_get_exceptionptrptr, REG_ITMP1);
                        i386_call_reg(REG_ITMP1);
@@ -4836,7 +4828,39 @@ gen_method: {
                        i386_mov_membase_reg(REG_ITMP3, 0, REG_ITMP1_XPTR);
                        i386_mov_imm_membase(0, REG_ITMP3, 0);
 #endif
+                       i386_push_imm(0);
+                       i386_push_reg(REG_ITMP1_XPTR);
+
+/*get the fillInStackTrace Method ID. I simulate a native call here, because I do not want to mess around with the
+java stack at this point*/
+                       i386_mov_membase_reg(REG_ITMP1_XPTR, OFFSET(java_objectheader, vftbl), REG_ITMP3);
+                       i386_mov_membase_reg(REG_ITMP3, OFFSET(vftbl,class), REG_ITMP1);
+                       i386_push_imm(utf_fillInStackTrace_desc);
+                       i386_push_imm(utf_fillInStackTrace_name);
+                       i386_push_reg(REG_ITMP1);
+                       i386_mov_imm_reg((s4) class_resolvemethod, REG_ITMP3);
+                       i386_call_reg(REG_ITMP3);
+/*cleanup parameters of class_resolvemethod*/
+                       i386_alu_imm_reg(I386_ADD,3*4 /*class reference + 2x string reference*/,REG_SP);
+/*prepare call to asm_calljavafunction2 */                     
+                       i386_push_imm(0);
+                       i386_push_imm(TYPE_ADR); /* --> call block (TYPE,Exceptionptr), each 8 byte  (make this dynamic) (JOWENN)*/
+                       i386_push_reg(REG_SP);
+                       i386_push_imm(sizeof(jni_callblock));
+                       i386_push_imm(1);
+                       i386_push_reg(REG_RESULT);
+                       
+                       i386_mov_imm_reg((s4) asm_calljavafunction2, REG_ITMP3);
+                       i386_call_reg(REG_ITMP3);
+
+                       /* check exceptionptr + fail (JOWENN)*/                 
+
+                       i386_alu_imm_reg(I386_ADD,6*4,REG_SP);
+
+                       i386_pop_reg(REG_ITMP1_XPTR);
+                       i386_pop_reg(REG_ITMP3); /* just remove the no longer needed 0 from the stack*/
                        REMOVE_NATIVE_STACKINFO
+
                        i386_pop_reg(REG_ITMP2_XPC);
 
                        i386_mov_imm_reg((s4) asm_handle_exception, REG_ITMP3);
index 04eabc763c829e8e473a8feb39a9c10810d1cda4..27a93a70cbec0f961a72e29b0b65af1d8496a727 100644 (file)
@@ -29,7 +29,7 @@
 
    Changes: Edwin Steiner
 
-   $Id: jit.c 1093 2004-05-27 15:49:43Z twisti $
+   $Id: jit.c 1112 2004-05-31 15:47:20Z jowenn $
 
 */
 
@@ -794,8 +794,7 @@ int jcommandsize[256] = {
        1,
 #define ICMD_CHECKEXCEPTION   203
        1, /* unused */
-
-             1,1,1,1,1,1,1,            /* unused */
+       1,1,1,1,1,1,1,            /* unused */
        1,1,1,1,1,1,1,1,1,1,
        1,1,1,1,1,1,1,1,1,1,
        1,1,1,1,1,1,1,1,1,1,
@@ -1008,9 +1007,8 @@ char *icmd_names[256] = {
        "UNDEF200     ", /* GOTO_W      200 */
        "UNDEF201     ", /* JSR_W       201 */
        "UNDEF202     ", /* BREAKPOINT  202 */
-       "CHECKEXCEPTION", /* UNDEF204    203 */
-
-                                        "UNDEF204","UNDEF205",
+       "CHECKEXCEPTION", /* UNDEF203    203 */
+                                       "UNDEF204", "UNDEF205",
        "UNDEF206","UNDEF207","UNDEF208","UNDEF209","UNDEF210",
        "UNDEF","UNDEF","UNDEF","UNDEF","UNDEF",
        "UNDEF216","UNDEF217","UNDEF218","UNDEF219","UNDEF220",
@@ -1233,8 +1231,7 @@ char *opcode_names[256] = {
        "JSR_W        ", /* JSR_W       201 */
        "BREAKPOINT   ", /* BREAKPOINT  202 */
        "CHECKEXCEPTION", /* UNDEF203    203 */
-
-                                        "UNDEF204","UNDEF205",
+                                        "UNDEF204","UNDEF205",
        "UNDEF206","UNDEF207","UNDEF208","UNDEF209","UNDEF210",
        "UNDEF","UNDEF","UNDEF","UNDEF","UNDEF",
        "UNDEF216","UNDEF217","UNDEF218","UNDEF219","UNDEF220",
index 70aca732c3b71d20ee666ca726bc7fd559333675..e33fd85bc37c2818c5fa97dec1e93092a3d229e2 100644 (file)
@@ -28,7 +28,7 @@
 
    Changes: Edwin Steiner
 
-   $Id: stack.c 1095 2004-05-27 15:54:42Z twisti $
+   $Id: stack.c 1112 2004-05-31 15:47:20Z jowenn $
 
 */
 
@@ -2773,7 +2773,7 @@ void show_icmd(instruction *iptr,bool deadcode)
                }
                break;
        }
-       printf(" Line number: %d, class:",iptr->line);
+       printf(" Line number: %d, method:",iptr->line);
        utf_display(iptr->method->class->name);
        printf(".");
        utf_display(iptr->method->name);
index 3864f29af0818707d2788f054e8dfc44efb89f30..4b094d28db29760a2f64246ee2d96b93e020d71d 100644 (file)
@@ -30,7 +30,7 @@
             Mark Probst
                        Edwin Steiner
 
-   $Id: loader.c 1110 2004-05-28 21:45:51Z jowenn $
+   $Id: loader.c 1112 2004-05-31 15:47:20Z jowenn $
 
 */
 
@@ -96,6 +96,8 @@ static utf *utf_initialize;
 static utf *utf_initializedesc;
 static utf *utf_java_lang_Object;   /* java/lang/Object                       */
 
+utf *utf_fillInStackTrace_name;
+utf *utf_fillInStackTrace_desc;
 
 utf* clinit_desc(){
        return utf_fidesc;
@@ -1832,7 +1834,7 @@ classinfo *class_load(classinfo *c)
                *exceptionptr =
                        new_exception_utfmessage(string_java_lang_NoClassDefFoundError,
                                                                         c->name);
-
+/*             log_text("Leaving class_load with NoClassDefFoundError");*/
 #if defined(USE_THREADS)
 #if defined(NATIVE_THREADS)
                tables_unlock();
@@ -3155,12 +3157,20 @@ methodinfo *class_resolvemethod_approx(classinfo *c, utf *name, utf *desc)
 
 methodinfo *class_resolvemethod(classinfo *c, utf *name, utf *desc)
 {
+       /*log_text("Trying to resolve a method");
+       utf_display(c->name);
+       utf_display(name);
+       utf_display(desc);*/
+
        while (c) {
+               /*log_text("Looking in:");
+               utf_display(c->name);*/
                methodinfo *m = class_findmethod(c, name, desc);
                if (m) return m;
                /* search superclass */
                c = c->super;
        }
+       /*log_text("method not found:");*/
 
        return NULL;
 }
@@ -4011,6 +4021,8 @@ void loader_init(u1 *stackbottom)
        utf_vmclass         = utf_new_char("java/lang/VMClass");
        utf_java_lang_Object= utf_new_char("java/lang/Object");
        array_packagename   = utf_new_char("<the array package>");
+       utf_fillInStackTrace_name = utf_new_char("fillInStackTrace");
+       utf_fillInStackTrace_desc = utf_new_char("()Ljava/lang/Throwable;");
 
        /* create some important classes */
        /* These classes have to be created now because the classinfo
index 32e0289a05c634f75e16e8355101cc15d562f7cc..ac745609894dc46e40168a61989eb0ed1856c9c8 100644 (file)
@@ -26,7 +26,7 @@
 
    Authors: Reinhard Grafl
 
-   $Id: loader.h 1088 2004-05-26 21:32:34Z twisti $
+   $Id: loader.h 1112 2004-05-31 15:47:20Z jowenn $
 */
 
 
@@ -63,7 +63,8 @@ extern classinfo *class_java_lang_Object;
 extern classinfo *class_java_lang_String;
 extern classinfo *class_java_lang_Cloneable;
 extern classinfo *class_java_io_Serializable;
-
+extern utf *utf_fillInStackTrace_name;
+extern utf *utf_fillInStackTrace_desc;
 
 /* pseudo classes for the type checker ****************************************/
 
index 87ecce26289c977f67fa2a3705407fe69baaa1d6..9f75882a57937513a04b1c1c14d201fb557b36b6 100644 (file)
@@ -1,5 +1,12 @@
 public class extest {
+
+    public static boolean printStackTrace;
+
     public static void main(String[] argv) {
+       printStackTrace=false;
+       if (argv.length>0) 
+               if (argv[0].equals("stacktrace")) printStackTrace=true;
+
         boolean catched = false;
 
        pln("---------- normal exceptions --------------------");
@@ -10,6 +17,8 @@ public class extest {
        } catch (Exception e) {
             catched = true;
            pln("OK");
+           pstacktrace(e);
+
        }
 
         /* check if catch block was executed */
@@ -23,6 +32,7 @@ public class extest {
             pln("FAILED");
        } catch (Exception e) {
            pln("OK");
+           pstacktrace(e);
        }
 
         try {
@@ -32,6 +42,7 @@ public class extest {
             pln("FAILED");
         } catch (NullPointerException e) {
            pln("OK");
+           pstacktrace(e);
        }
 
        try {
@@ -61,6 +72,7 @@ public class extest {
 
            } else {
                pln("OK");
+               pstacktrace(e);
            }
        }
 
@@ -77,6 +89,8 @@ public class extest {
 
            } else {
                pln("OK");
+               pstacktrace(e);
+
            }
        }
 
@@ -87,6 +101,7 @@ public class extest {
             pln("FAILED");
         } catch (NegativeArraySizeException e) {
            pln("OK");
+           pstacktrace(e);
        }
 
         try {
@@ -95,6 +110,7 @@ public class extest {
             pln("FAILED");
         } catch (NegativeArraySizeException e) {
            pln("OK");
+           pstacktrace(e);
        }
 
         
@@ -115,6 +131,7 @@ public class extest {
             pln("FAILED");
         } catch (ClassCastException e) {
            pln("OK");
+           pstacktrace(e);
        }
 
 
@@ -125,6 +142,7 @@ public class extest {
             pln("FAILED");
         } catch (OutOfMemoryError e) {
            pln("OK");
+           pstacktrace(e);
        }
 
         try {
@@ -134,6 +152,7 @@ public class extest {
             pln("FAILED");
         } catch (OutOfMemoryError e) {
            pln("OK");
+           pstacktrace(e);
        }
         
 
@@ -144,6 +163,7 @@ public class extest {
             pln("FAILED");
         } catch (NullPointerException e) {
            pln("OK");
+           pstacktrace(e);
        }
 
         try {
@@ -153,6 +173,7 @@ public class extest {
             pln("FAILED");
         } catch (NullPointerException e) {
            pln("OK");
+           pstacktrace(e);
        }
 
        pln();
@@ -167,9 +188,9 @@ public class extest {
         } catch (ExceptionInInitializerError e) {
             if (e.getCause().getClass() != NullPointerException.class) {
                 pln("FAILED");
-
             } else {
                 pln("OK");
+               pstacktrace(e);
             }
         }
 
@@ -179,6 +200,7 @@ public class extest {
             pln("FAILED");
         } catch (ArithmeticException e) {
            pln("OK");
+           pstacktrace(e);
        }
 
         try {
@@ -187,6 +209,7 @@ public class extest {
             pln("FAILED");
         } catch (ArithmeticException e) {
            pln("OK");
+           pstacktrace(e);
        }
 
         try {
@@ -195,6 +218,7 @@ public class extest {
             pln("FAILED");
         } catch (ArithmeticException e) {
            pln("OK");
+           pstacktrace(e);
        }
 
         try {
@@ -203,6 +227,7 @@ public class extest {
             pln("FAILED");
         } catch (ArithmeticException e) {
            pln("OK");
+           pstacktrace(e);
        }
 
         try {
@@ -212,6 +237,7 @@ public class extest {
             pln("FAILED");
         } catch (NullPointerException e) {
            pln("OK");
+           pstacktrace(e);
        }
 
         try {
@@ -221,6 +247,7 @@ public class extest {
             pln("FAILED");
         } catch (ArrayIndexOutOfBoundsException e) {
            pln("OK");
+           pstacktrace(e);
        }
 
         try {
@@ -231,6 +258,7 @@ public class extest {
             pln("FAILED");
         } catch (ArrayStoreException e) {
            pln("OK");
+           pstacktrace(e);
        }
 
         try {
@@ -240,6 +268,7 @@ public class extest {
             pln("FAILED");
         } catch (ClassCastException e) {
            pln("OK");
+           pstacktrace(e);
        }
 
        pln();
@@ -255,6 +284,7 @@ public class extest {
                otherwise this test in useless */
         } catch (Exception e) {
            pln("OK");
+           pstacktrace(e);
        }
 
         pln();
@@ -298,4 +328,12 @@ public class extest {
     public static void pln(String s) {
        System.out.println(s);
     }
+
+    public static void pstacktrace(Throwable e) {
+       if (!printStackTrace) return;
+       System.out.println("================== Stacktrace");
+       e.printStackTrace();
+       System.out.println("Stacktrace ==================");
+    }
+
 }
diff --git a/tests/stack/README b/tests/stack/README
new file mode 100644 (file)
index 0000000..59de499
--- /dev/null
@@ -0,0 +1,21 @@
+for additional exception test, remove the _clinit2,3,.. or _1,_2... class files. One at a time, after compilation.
+
+
+Lazy loading/binding problem ?
+If you delete nestedconstructorexception2_1.class and run the nestedconstructorexception2 class
+
+The cacao stack results in:
+java.lang.NoClassDefFoundError: nestedconstructorexception2_1
+   at nestedconstructorexception2.main (nestedconstructorexception2.java:34)
+
+
+The same testcase with java:
+
+Something caught in constructor
+Something caught in constructor
+Something caught in constructor
+java.lang.NoClassDefFoundError: nestedconstructorexception2_1
+       at nestedconstructorexception2.<init>(nestedconstructorexception2.java:20)
+       at nestedconstructorexception2.<init>(nestedconstructorexception2.java:17)
+       at nestedconstructorexception2.<init>(nestedconstructorexception2.java:14)
+       at nestedconstructorexception2.main(nestedconstructorexception2.java:34)
index 7b126ebd4ad25230e8f3d95144e8080331d78862..74618a6f701c28383828be2d65e239c59c9865b6 100644 (file)
@@ -44,7 +44,7 @@ public class exception {
                } catch (Exception e) {
                        System.out.println(e.getMessage());
                        e.printStackTrace();
-                       System.out.println("Caught in c(), refilling stacktrace and  rethrowing");
+                       System.out.println("Caught in e(), refilling stacktrace and  rethrowing");
                        e.fillInStackTrace();
                        throw e;
                }
diff --git a/tests/stack/inheritancetest.java b/tests/stack/inheritancetest.java
new file mode 100644 (file)
index 0000000..c164568
--- /dev/null
@@ -0,0 +1,21 @@
+class inheritancetest_2 {
+       inheritancetest_2() {
+               System.out.println("inerhitancetest_2");
+       }
+}
+
+class inheritancetest_1 extends inheritancetest_2 {
+       inheritancetest_1() {
+               System.out.println("inerhitancetest_1");
+       }
+}
+
+public class inheritancetest {
+       public static void main(String args[]) {
+               try {
+                       inheritancetest_1 x=new inheritancetest_1();
+               } catch (Throwable t) {
+                       t.printStackTrace();
+               }
+       }
+}
index 9960674c93e83c91af27b8e65d38bcdc3905398b..9c1e3e88ced2765330423483b69ac7e225004398 100644 (file)
@@ -1,7 +1,16 @@
-all:
+all: testlib1 testlib2
+
+testlib1:
        javac stackTraceTest1.java
        gcc -shared -o libstackTraceTest1.so stackTraceTest1.c
+
+testlib2:
+       javac stackTraceTest2.java
+       gcc -shared -o libstackTraceTest2.so stackTraceTest2.c
 clean:
        rm -f libstackTraceTest1.so stackTraceTest1.class
+       rm -f libstackTraceTest2.so stackTraceTest2.class
 test:
        LD_LIBRARY_PATH=$LD_LIBRARY_PATH:`pwd` java stackTraceTest1
+       LD_LIBRARY_PATH=$LD_LIBRARY_PATH:`pwd` java stackTraceTest2
+
index 09f8b03a4656313d6cb16a278ea63e0f006edd6f..e62fc3c9dea6abbd4a0dc074cefcb9d19b6b2e26 100644 (file)
@@ -1,3 +1,4 @@
+/*GPL license Joseph Wenninger 2004*/
 #include "stackTraceTest1.h"
 
 void JNICALL Java_stackTraceTest1_b_nested
index d711eb2232c8ece830c4e3320dc2609d4e244197..fe4c2367f4b13d067bb3d55d2af2dc2580c3d77f 100644 (file)
@@ -1,4 +1,4 @@
-
+/*GPL Licene Joseph Wenninger 2004*/
 public class stackTraceTest1 {
 
        public static void a() throws Exception {
diff --git a/tests/stack/nestedconstructorexception.java b/tests/stack/nestedconstructorexception.java
new file mode 100644 (file)
index 0000000..25516ea
--- /dev/null
@@ -0,0 +1,29 @@
+public class nestedconstructorexception {
+
+       public nestedconstructorexception(int val) throws Throwable {
+               switch (val) {
+                       case 1:
+                               nestedconstructorexception y=new nestedconstructorexception(2);
+                               break;
+                       case 2:
+                               nestedconstructorexception y1=new nestedconstructorexception(3);
+                               break;
+                       case 3:
+                               String a[]=new String[10];
+                               Object o=new nestedconstructorexception(5);
+                               a[0]=(String)o;
+                               break;
+                       default:
+
+               }
+       }
+
+
+       public static void main (String args[]) {
+               try {
+                       nestedconstructorexception x=new nestedconstructorexception(1);
+               } catch (Throwable t) {
+                       t.printStackTrace();
+               }
+       }
+}
diff --git a/tests/stack/nestedconstructorexception2.java b/tests/stack/nestedconstructorexception2.java
new file mode 100644 (file)
index 0000000..c6e8157
--- /dev/null
@@ -0,0 +1,39 @@
+class nestedconstructorexception2_1 {
+               nestedconstructorexception2_1() {
+                       String s=null;
+                       s.length();
+               }
+}
+
+public class nestedconstructorexception2 {
+
+       public nestedconstructorexception2(int val) throws Throwable {
+               try {
+                       switch (val) {
+                               case 1:
+                                       nestedconstructorexception2 y=new nestedconstructorexception2(2);
+                                       break;
+                               case 2:
+                                       nestedconstructorexception2 y1=new nestedconstructorexception2(3);
+                                       break;
+                               case 3:
+                                       Object o=new nestedconstructorexception2_1();
+                                       break;
+                               default:
+
+                       }
+               } catch (Throwable t) {
+                       System.out.println("Something caught in constructor");
+                       throw t;
+               }
+       }
+
+
+       public static void main (String args[]) {
+               try {
+                       nestedconstructorexception2 x=new nestedconstructorexception2(1);
+               } catch (Throwable t) {
+                       t.printStackTrace();
+               }
+       }
+}
diff --git a/tests/stack/nestedstaticinitializers.java b/tests/stack/nestedstaticinitializers.java
new file mode 100644 (file)
index 0000000..7a3d237
--- /dev/null
@@ -0,0 +1,33 @@
+class nestedstaticinitializers_clinit1 {
+       public static int x;
+       static {
+               nestedstaticinitializers_clinit2.x=3;
+       }
+
+}
+
+class nestedstaticinitializers_clinit2 {
+       public static int x;
+       static {
+               nestedstaticinitializers_clinit3.x=3;
+       }
+
+}
+
+class nestedstaticinitializers_clinit3 {
+       public static int x;
+       static {
+               int y[]=new int[-1];
+       }
+
+}
+
+class nestedstaticinitializers {
+       public static void main (String args[]) {
+               try {
+                       nestedstaticinitializers_clinit1.x=3;
+               } catch (Throwable t) {
+                       t.printStackTrace();
+               }
+       }
+}