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 $
*/
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);
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 $
*/
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
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 $
*/
/* data structure for calls from c code to java methods */
struct jni_callblock {
- u1 itemtype;
+ u8 itemtype;
u8 item;
};
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 $
*/
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));
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 $
*/
}
+#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
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
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
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
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
pop %ecx /* delete return address */
sub $2,%ecx /* faulting address is return adress - 2 */
jmp asm_handle_exception
-
+#endif
/********************* function 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
pop %ecx /* delete return address */
sub $2,%ecx /* faulting address is return adress - 2 */
jmp asm_handle_exception
-
+#endif
/************************ function 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
pop %ecx /* delete return address */
sub $2,%ecx /* faulting address is return adress - 2 */
jmp asm_handle_exception
-
+#endif
/************************ function 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
pop %ecx /* delete return address */
sub $2,%ecx /* faulting address is return adress - 2 */
jmp asm_handle_exception
-
+#endif
/************************ function asm_builtin_x2x *****************************
* *
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
pop %ecx /* delete return address */
sub $2,%ecx /* faulting address is return adress - 2 */
jmp asm_handle_exception
-
+#endif
/******************* function asm_builtin_newarray *****************************
* *
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
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
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
pop %ecx /* delete return address */
sub $2,%ecx /* faulting address is return adress - 2 */
jmp asm_handle_exception
-
+#endif
/******************* function asm_builtin_arrayinstanceof **********************
* *
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)
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
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 $
*/
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)
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;
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) {
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);
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);
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);
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 $
*/
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,
"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",
"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",
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 $
*/
}
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);
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 $
*/
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);
}
);
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;
}
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;
}
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 $
*/
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;
*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();
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;
}
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
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 $
*/
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 ****************************************/
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);
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);
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);}
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);
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);
(*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);
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)) {
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)) {
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 $
*/
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");
}
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()");
+
+ }
}
}
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);
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);
}
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);
}
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 $
*/
}
+#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)));
}
{
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));
}
{
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)));
}
{
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));
}
{
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));
}
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 $
*/
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));
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 $
*/
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);
}
);
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;
}
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;
}
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 $
*/
}
+#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)));
}
{
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));
}
{
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)));
}
{
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));
}
{
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));
}
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 $
*/
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");
}
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()");
+
+ }
}
}
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 $
*/
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
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 $
*/
/* data structure for calls from c code to java methods */
struct jni_callblock {
- u1 itemtype;
+ u8 itemtype;
u8 item;
};
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 $
*/
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);
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 $
*/
}
+#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
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
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
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
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
pop %ecx /* delete return address */
sub $2,%ecx /* faulting address is return adress - 2 */
jmp asm_handle_exception
-
+#endif
/********************* function 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
pop %ecx /* delete return address */
sub $2,%ecx /* faulting address is return adress - 2 */
jmp asm_handle_exception
-
+#endif
/************************ function 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
pop %ecx /* delete return address */
sub $2,%ecx /* faulting address is return adress - 2 */
jmp asm_handle_exception
-
+#endif
/************************ function 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
pop %ecx /* delete return address */
sub $2,%ecx /* faulting address is return adress - 2 */
jmp asm_handle_exception
-
+#endif
/************************ function asm_builtin_x2x *****************************
* *
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
pop %ecx /* delete return address */
sub $2,%ecx /* faulting address is return adress - 2 */
jmp asm_handle_exception
-
+#endif
/******************* function asm_builtin_newarray *****************************
* *
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
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
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
pop %ecx /* delete return address */
sub $2,%ecx /* faulting address is return adress - 2 */
jmp asm_handle_exception
-
+#endif
/******************* function asm_builtin_arrayinstanceof **********************
* *
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)
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
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 $
*/
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)
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;
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) {
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);
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);
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);
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 $
*/
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,
"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",
"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",
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 $
*/
}
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);
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 $
*/
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;
*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();
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;
}
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
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 $
*/
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 ****************************************/
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 --------------------");
} catch (Exception e) {
catched = true;
pln("OK");
+ pstacktrace(e);
+
}
/* check if catch block was executed */
pln("FAILED");
} catch (Exception e) {
pln("OK");
+ pstacktrace(e);
}
try {
pln("FAILED");
} catch (NullPointerException e) {
pln("OK");
+ pstacktrace(e);
}
try {
} else {
pln("OK");
+ pstacktrace(e);
}
}
} else {
pln("OK");
+ pstacktrace(e);
+
}
}
pln("FAILED");
} catch (NegativeArraySizeException e) {
pln("OK");
+ pstacktrace(e);
}
try {
pln("FAILED");
} catch (NegativeArraySizeException e) {
pln("OK");
+ pstacktrace(e);
}
pln("FAILED");
} catch (ClassCastException e) {
pln("OK");
+ pstacktrace(e);
}
pln("FAILED");
} catch (OutOfMemoryError e) {
pln("OK");
+ pstacktrace(e);
}
try {
pln("FAILED");
} catch (OutOfMemoryError e) {
pln("OK");
+ pstacktrace(e);
}
pln("FAILED");
} catch (NullPointerException e) {
pln("OK");
+ pstacktrace(e);
}
try {
pln("FAILED");
} catch (NullPointerException e) {
pln("OK");
+ pstacktrace(e);
}
pln();
} catch (ExceptionInInitializerError e) {
if (e.getCause().getClass() != NullPointerException.class) {
pln("FAILED");
-
} else {
pln("OK");
+ pstacktrace(e);
}
}
pln("FAILED");
} catch (ArithmeticException e) {
pln("OK");
+ pstacktrace(e);
}
try {
pln("FAILED");
} catch (ArithmeticException e) {
pln("OK");
+ pstacktrace(e);
}
try {
pln("FAILED");
} catch (ArithmeticException e) {
pln("OK");
+ pstacktrace(e);
}
try {
pln("FAILED");
} catch (ArithmeticException e) {
pln("OK");
+ pstacktrace(e);
}
try {
pln("FAILED");
} catch (NullPointerException e) {
pln("OK");
+ pstacktrace(e);
}
try {
pln("FAILED");
} catch (ArrayIndexOutOfBoundsException e) {
pln("OK");
+ pstacktrace(e);
}
try {
pln("FAILED");
} catch (ArrayStoreException e) {
pln("OK");
+ pstacktrace(e);
}
try {
pln("FAILED");
} catch (ClassCastException e) {
pln("OK");
+ pstacktrace(e);
}
pln();
otherwise this test in useless */
} catch (Exception e) {
pln("OK");
+ pstacktrace(e);
}
pln();
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 ==================");
+ }
+
}
--- /dev/null
+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)
} 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;
}
--- /dev/null
+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();
+ }
+ }
+}
-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
+
+/*GPL license Joseph Wenninger 2004*/
#include "stackTraceTest1.h"
void JNICALL Java_stackTraceTest1_b_nested
-
+/*GPL Licene Joseph Wenninger 2004*/
public class stackTraceTest1 {
public static void a() throws Exception {
--- /dev/null
+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();
+ }
+ }
+}
--- /dev/null
+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();
+ }
+ }
+}
--- /dev/null
+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();
+ }
+ }
+}