* src/vmcore/loader.c (load_class_from_classbuffer_intern): Also call
[cacao.git] / src / vmcore / loader.c
index 346fb3ad8239f3f0a6da79595410542cb5a49e94..1c0efb1e6cc7f2354f7f333a24279bb019779208 100644 (file)
@@ -1,9 +1,7 @@
 /* src/vmcore/loader.c - class loader 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.
 
@@ -100,7 +98,11 @@ void loader_preinit(void)
 {
 #if defined(ENABLE_THREADS)
        list_classpath_entry *lce;
+#endif
+
+       TRACESUBSYSTEMINITIALIZATION("loader_preinit");
 
+#if defined(ENABLE_THREADS)
        /* Initialize the monitor pointer for zip/jar file locking. */
 
        for (lce = list_first(list_classpath_entries); lce != NULL;
@@ -139,6 +141,8 @@ void loader_preinit(void)
  
 void loader_init(void)
 {
+       TRACESUBSYSTEMINITIALIZATION("loader_init");
+
        /* Load primitive-type wrapping classes. */
 
        assert(vm_initializing == true);
@@ -193,6 +197,16 @@ void loader_init(void)
                load_class_bootstrap(utf_new_char("java/lang/VMThrowable"));
 #endif
 
+       /* Important system exceptions. */
+
+       class_java_lang_Exception  = load_class_bootstrap(utf_java_lang_Exception);
+
+       class_java_lang_ClassNotFoundException =
+               load_class_bootstrap(utf_java_lang_ClassNotFoundException);
+
+       class_java_lang_RuntimeException =
+               load_class_bootstrap(utf_java_lang_RuntimeException);
+
        /* Some classes which may be used often. */
 
 #if defined(ENABLE_JAVASE)
@@ -211,6 +225,9 @@ void loader_init(void)
        class_java_security_PrivilegedAction =
                load_class_bootstrap(utf_new_char("java/security/PrivilegedAction"));
 
+       class_java_util_HashMap = 
+               load_class_bootstrap(utf_new_char("java/util/HashMap"));
+
        class_java_util_Vector     = load_class_bootstrap(utf_java_util_Vector);
 
 # if defined(WITH_CLASSPATH_SUN)
@@ -260,12 +277,7 @@ classloader *loader_hashtable_classloader_add(java_handle_t *cl)
        /* key for entry is the hashcode of the classloader;
           aligned to 16-byte boundaries */
 
-#if defined(ENABLE_GC_CACAO)
-       key  = heap_get_hashcode(LLNI_DIRECT(cl)) >> 4;
-#else
-       key  = ((u4) (ptrint) cl) >> 4;
-#endif
-
+       key  = heap_hashcode(LLNI_DIRECT(cl)) >> 4;
        slot = key & (hashtable_classloader->size - 1);
        cle  = hashtable_classloader->ptr[slot];
 
@@ -346,12 +358,7 @@ classloader *loader_hashtable_classloader_find(java_handle_t *cl)
        /* key for entry is the hashcode of the classloader;
           aligned to 16-byte boundaries */
 
-#if defined(ENABLE_GC_CACAO)
-       key  = heap_get_hashcode(LLNI_DIRECT(cl)) >> 4;
-#else
-       key  = ((u4) (ptrint) cl) >> 4;
-#endif
-
+       key  = heap_hashcode(LLNI_DIRECT(cl)) >> 4;
        slot = key & (hashtable_classloader->size - 1);
        cle  = hashtable_classloader->ptr[slot];
 
@@ -1646,8 +1653,10 @@ static bool load_class_from_classbuffer_intern(classbuffer *cb)
                /* XXX This should be done better. */
                tc = resolve_classref_or_classinfo_eager(CLASSREF_OR_CLASSINFO(cr), false);
 
-               if (tc == NULL)
+               if (tc == NULL) {
+                       resolve_handle_pending_exception(true);
                        return false;
+               }
 
                /* Interfaces are not allowed as super classes. */
 
@@ -1681,8 +1690,10 @@ static bool load_class_from_classbuffer_intern(classbuffer *cb)
                /* XXX This should be done better. */
                tc = resolve_classref_or_classinfo_eager(CLASSREF_OR_CLASSINFO(cr), false);
 
-               if (tc == NULL)
+               if (tc == NULL) {
+                       resolve_handle_pending_exception(true);
                        return false;
+               }
 
                /* Detect circularity. */
 
@@ -1939,8 +1950,8 @@ static bool load_class_from_classbuffer_intern(classbuffer *cb)
 classinfo *load_class_from_classbuffer(classbuffer *cb)
 {
        classinfo *c;
-       int32_t    dumpsize;
        bool       result;
+       int32_t    dumpmarker;
 
        /* Get the classbuffer's class. */
 
@@ -1963,7 +1974,7 @@ classinfo *load_class_from_classbuffer(classbuffer *cb)
 
        /* Mark start of dump memory area. */
 
-       dumpsize = dump_size();
+       DMARKER;
 
        /* Class is currently loading. */
 
@@ -1975,7 +1986,7 @@ classinfo *load_class_from_classbuffer(classbuffer *cb)
 
        /* Release dump area. */
 
-       dump_release(dumpsize);
+       DRELEASE;
 
        /* An error occurred. */