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 <string.h>
+#include "config.h"
+#include "vm/types.h"
+
#include "vm/global.h"
#include "vm/initialize.h"
#include "vm/builtin.h"
}
/* 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)
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
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);
/* 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;