* Fixed typo
[cacao.git] / src / vm / initialize.c
index 1a12b0ba97fa562609f249e23247cb4ed842c529..fbb14f679b94b25ea8be717c690b6217470f2b74 100644 (file)
             Andreas Krall
             Christian Thalinger
 
-   $Id: initialize.c 2197 2005-04-03 21:39:07Z twisti $
+   $Id: initialize.c 2592 2005-06-08 11:03:52Z twisti $
 
 */
 
 
 #include <string.h>
 
-#include "config.h"
+#include "vm/global.h"
+#include "vm/initialize.h"
 #include "vm/builtin.h"
 #include "vm/class.h"
+#include "vm/loader.h"
 #include "vm/exceptions.h"
-#include "vm/global.h"
 #include "vm/options.h"
 #include "vm/statistics.h"
 #include "vm/stringlocal.h"
 #include "vm/jit/asmpart.h"
 
+#undef JWDEBUG
 
 /* private functions **********************************************************/
 
@@ -90,6 +92,9 @@ bool initialize_class(classinfo *c)
                return true;
        }
 
+#ifdef JWDEBUG
+       printf("preparing to call initialize_class_intern for %s\n",c->name->text);
+#endif
        /* this initalizing run begins NOW */
        c->initializing = true;
 
@@ -101,6 +106,10 @@ bool initialize_class(classinfo *c)
        if (r)
                c->initialized = true;
 
+#ifdef JWDEBUG
+       printf("finished to call initialize_class_intern for %s\n",c->name->text);
+#endif
+
        /* this initalizing run is done */
        c->initializing = false;
 
@@ -123,8 +132,9 @@ bool initialize_class(classinfo *c)
 
 static bool initialize_class_intern(classinfo *c)
 {
-       methodinfo *m;
-       s4 i;
+       methodinfo        *m;
+       java_objectheader *xptr;
+       s4                 i;
 #if defined(USE_THREADS) && !defined(NATIVE_THREADS)
        int b;
 #endif
@@ -144,15 +154,15 @@ 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);
+
+#ifdef JWDEBUG
+                       printf("preparing to call initialize_class for super  %s\n",c->super.cls->name->text);
+#endif
                        if (!initialize_class(c->super.cls))
                                return false;
                }
@@ -162,14 +172,14 @@ static bool initialize_class_intern(classinfo *c)
 
        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);
-                       }
+#ifdef JWDEBUG
+                       printf("preparing to call initialize_class for interface  %s\n",c->interfaces[i].cls->name->text);
+#endif
+                       if (initverbose)
+                               log_message_class_message_class("Initialize interface class ",
+                                                                                               c->interfaces[i].cls,
+                                                                                               " from ",
+                                                                                               c);
                        
                        if (!initialize_class(c->interfaces[i].cls))
                                return false;
@@ -179,20 +189,15 @@ static bool initialize_class_intern(classinfo *c)
        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);
@@ -213,39 +218,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;