X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=src%2Fvm%2Finitialize.c;h=e04886372f60bdedab3b269caff72cd7208afeb4;hb=ac8875dee8e088175bb2c0d1e3531e3ae2ff509f;hp=f1d88c691219cb9626fbc192a0b641f8e35c72a8;hpb=99443f7c677108132d9da01a2b932bfeac05e06b;p=cacao.git diff --git a/src/vm/initialize.c b/src/vm/initialize.c index f1d88c691..e04886372 100644 --- a/src/vm/initialize.c +++ b/src/vm/initialize.c @@ -30,13 +30,16 @@ Andreas Krall Christian Thalinger - $Id: initialize.c 2213 2005-04-04 13:05:15Z edwin $ + $Id: initialize.c 3339 2005-10-04 20:19:11Z twisti $ */ #include +#include "config.h" +#include "vm/types.h" + #include "vm/global.h" #include "vm/initialize.h" #include "vm/builtin.h" @@ -92,17 +95,21 @@ bool initialize_class(classinfo *c) } /* this initalizing run begins NOW */ + c->initializing = true; /* call the internal function */ + r = initialize_class_intern(c); - /* if return value is not NULL everything was ok and the class is - initialized */ + /* if return value is not NULL everything was ok and the class is */ + /* initialized */ + if (r) c->initialized = true; /* this initalizing run is done */ + c->initializing = false; #if defined(USE_THREADS) @@ -124,8 +131,8 @@ bool initialize_class(classinfo *c) static bool initialize_class_intern(classinfo *c) { - methodinfo *m; - s4 i; + methodinfo *m; + java_objectheader *xptr; #if defined(USE_THREADS) && !defined(NATIVE_THREADS) int b; #endif @@ -145,55 +152,31 @@ static bool initialize_class_intern(classinfo *c) if (c->super.cls) { if (!c->super.cls->initialized) { - if (initverbose) { - char logtext[MAXLOGTEXT]; - strcpy(logtext, "Initialize super class "); - utf_strcat_classname(logtext, c->super.cls->name); - strcat(logtext, " from "); - utf_strcat_classname(logtext, c->name); - log_text(logtext); - } + if (initverbose) + log_message_class_message_class("Initialize super class ", + c->super.cls, + " from ", + c); if (!initialize_class(c->super.cls)) return false; } } - /* initialize interface classes */ - - for (i = 0; i < c->interfacescount; i++) { - if (!c->interfaces[i].cls->initialized) { - if (initverbose) { - char logtext[MAXLOGTEXT]; - strcpy(logtext, "Initialize interface class "); - utf_strcat_classname(logtext, c->interfaces[i].cls->name); - strcat(logtext, " from "); - utf_strcat_classname(logtext, c->name); - log_text(logtext); - } - - if (!initialize_class(c->interfaces[i].cls)) - return false; - } - } + /* interfaces implemented need not to be initialized (VM Spec 2.17.4) */ m = class_findmethod(c, utf_clinit, utf_void__void); if (!m) { - if (initverbose) { - char logtext[MAXLOGTEXT]; - strcpy(logtext, "Class "); - utf_strcat_classname(logtext, c->name); - strcat(logtext, " has no static class initializer"); - log_text(logtext); - } + if (initverbose) + log_message_class("Class has no static class initializer: ", c); return true; } /* Sun's and IBM's JVM don't care about the static flag */ /* if (!(m->flags & ACC_STATIC)) { */ -/* panic("Class initializer is not static!"); */ +/* log_text("Class initializer is not static!"); */ if (initverbose) log_message_class("Starting static class initializer for class: ", c); @@ -214,39 +197,25 @@ static bool initialize_class_intern(classinfo *c) /* we have an exception or error */ - if (*exceptionptr) { + xptr = *exceptionptr; + + if (xptr) { /* class is NOT initialized */ c->initialized = false; /* is this an exception, than wrap it */ - if (builtin_instanceof(*exceptionptr, class_java_lang_Exception)) { - java_objectheader *xptr; - java_objectheader *cause; - - /* get the cause */ - - cause = *exceptionptr; - + if (builtin_instanceof(xptr, class_java_lang_Exception)) { /* clear exception, because we are calling jit code again */ *exceptionptr = NULL; /* wrap the exception */ - xptr = + *exceptionptr = new_exception_throwable(string_java_lang_ExceptionInInitializerError, - (java_lang_Throwable *) cause); - - /* XXX should we exit here? */ - - if (*exceptionptr) - throw_exception(); - - /* set new exception */ - - *exceptionptr = xptr; + (java_lang_Throwable *) xptr); } return false;