/* src/vm/initialize.c - static class initializer functions
- Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel,
- C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
- E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
- J. Wenninger, Institut f. Computersprachen - TU Wien
+ Copyright (C) 1996-2005, 2006, 2007, 2008
+ CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
This file is part of CACAO.
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: initialize.c 8295 2007-08-11 17:57:24Z michi $
-
*/
#include "threads/lock-common.h"
+#include "vm/jit/builtin.hpp"
+#include "vm/class.h"
+#include "vm/exceptions.hpp"
#include "vm/global.h"
+#include "vm/globals.hpp"
#include "vm/initialize.h"
-#include "vm/builtin.h"
-#include "vm/exceptions.h"
-#include "vm/stringlocal.h"
-#include "vm/vm.h"
-
-#include "vm/jit/asmpart.h"
-
-#include "vmcore/class.h"
-#include "vmcore/loader.h"
-#include "vmcore/options.h"
+#include "vm/loader.hpp"
+#include "vm/options.h"
+#include "vm/vm.hpp"
#if defined(ENABLE_STATISTICS)
-# include "vmcore/statistics.h"
+# include "vm/statistics.h"
#endif
+#include "vm/jit/asmpart.h"
+
/* private functions **********************************************************/
static bool initialize_class_intern(classinfo *c);
+/* initialize_init *************************************************************
+
+ Initialize important system classes.
+
+*******************************************************************************/
+
+void initialize_init(void)
+{
+ TRACESUBSYSTEMINITIALIZATION("initialize_init");
+
+#if defined(ENABLE_JAVASE)
+# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
+
+ /* Nothing. */
+
+# elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
+
+ if (!initialize_class(class_java_lang_String))
+ vm_abort("initialize_init: Initialization failed: java.lang.String");
+
+ if (!initialize_class(class_java_lang_System))
+ vm_abort("initialize_init: Initialization failed: java.lang.System");
+
+ if (!initialize_class(class_java_lang_ThreadGroup))
+ vm_abort("initialize_init: Initialization failed: java.lang.ThreadGroup");
+
+ if (!initialize_class(class_java_lang_Thread))
+ vm_abort("initialize_init: Initialization failed: java.lang.Thread");
+
+# else
+# error unknown classpath configuration
+# endif
+
+#elif defined(ENABLE_JAVAME_CLDC1_1)
+
+ /* Nothing. */
+
+#else
+# error unknown Java configuration
+#endif
+}
+
/* initialize_class ************************************************************
In Java, every class can have a static initialization
static bool initialize_class_intern(classinfo *c)
{
methodinfo *m;
- java_handle_t *xptr;
+ java_handle_t *cause;
+ classinfo *class;
/* maybe the class is not already linked */
count_class_inits++;
#endif
- /* initialize super class */
+ /* Initialize super class. */
- if (c->super.cls) {
- if (!(c->super.cls->state & CLASS_INITIALIZED)) {
+ if (c->super != NULL) {
+ if (!(c->super->state & CLASS_INITIALIZED)) {
#if !defined(NDEBUG)
if (initverbose)
log_message_class_message_class("Initialize super class ",
- c->super.cls,
+ c->super,
" from ",
c);
#endif
- if (!initialize_class(c->super.cls))
+ if (!initialize_class(c->super))
return false;
}
}
m = class_findmethod(c, utf_clinit, utf_void__void);
- if (!m) {
+ if (m == NULL) {
#if !defined(NDEBUG)
if (initverbose)
log_message_class("Class has no static class initializer: ", c);
/* we have an exception or error */
- xptr = exceptions_get_exception();
+ cause = exceptions_get_exception();
- if (xptr != NULL) {
+ if (cause != NULL) {
/* class is NOT initialized and is marked with error */
c->state |= CLASS_ERROR;
- /* is this an exception, than wrap it */
+ /* Load java/lang/Exception for the instanceof check. */
+
+ class = load_class_bootstrap(utf_java_lang_Exception);
+
+ if (class == NULL)
+ return false;
+
+ /* Is this an exception? Yes, than wrap it. */
- if (builtin_instanceof(xptr, class_java_lang_Exception)) {
+ if (builtin_instanceof(cause, class)) {
/* clear exception, because we are calling jit code again */
exceptions_clear_exception();
/* wrap the exception */
- exceptions_throw_exceptionininitializererror(xptr);
+ exceptions_throw_exceptionininitializererror(cause);
}
return false;