* autogen.sh: Made executeable.
[cacao.git] / src / vmcore / loader.c
index 9962c2c7d6ff6a40b654c9a702ca7b1cc8c6acec..060d0e2b3ec16f3971cae15dfb1e0628534a9a08 100644 (file)
@@ -22,8 +22,6 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: loader.c 8230 2007-07-25 08:23:10Z twisti $
-
 */
 
 
@@ -37,6 +35,8 @@
 
 #include "mm/memory.h"
 
+#include "native/llni.h"
+
 #include "threads/lock-common.h"
 
 #include "toolbox/logging.h"
@@ -44,6 +44,7 @@
 #include "vm/builtin.h"
 #include "vm/exceptions.h"
 #include "vm/global.h"
+#include "vm/primitive.h"
 #include "vm/stringlocal.h"
 #include "vm/vm.h"
 
@@ -60,7 +61,6 @@
 #include "vmcore/loader.h"
 #include "vmcore/method.h"
 #include "vmcore/options.h"
-#include "vmcore/primitive.h"
 #include "vmcore/rt-timing.h"
 
 #if defined(ENABLE_STATISTICS)
@@ -217,10 +217,31 @@ bool loader_init(void)
        if (!(class_java_util_Vector = load_class_bootstrap(utf_java_util_Vector)))
                return false;
 
+# if defined(WITH_CLASSPATH_SUN)
+       if (!(class_sun_reflect_MagicAccessorImpl =
+                 load_class_bootstrap(utf_new_char("sun/reflect/MagicAccessorImpl"))))
+               return false;
+# endif
+
        if (!(arrayclass_java_lang_Object =
                  load_class_bootstrap(utf_new_char("[Ljava/lang/Object;"))))
                return false;
+
+#if defined(ENABLE_ANNOTATIONS)
+       /* needed by annotation support */
+       if (!(class_sun_reflect_ConstantPool = 
+                 load_class_bootstrap(utf_new_char("sun/reflect/ConstantPool"))))
+               return false;
+
+#if defined(WITH_CLASSPATH_GNU)
+       /* needed by GNU Classpaths annotation support */
+       if (!(class_sun_reflect_annotation_AnnotationParser = 
+                 load_class_bootstrap(utf_new_char("sun/reflect/annotation/AnnotationParser"))))
+               return false;
+#endif
 #endif
+#endif
+
 
        return true;
 }
@@ -824,9 +845,9 @@ bool loader_load_attribute_signature(classbuffer *cb, utf **signature)
 
 classinfo *load_class_from_sysloader(utf *name)
 {
-       methodinfo        *m;
-       java_objectheader *cl;
-       classinfo         *c;
+       methodinfo  *m;
+       classloader *cl;
+       classinfo   *c;
 
        assert(class_java_lang_Object);
        assert(class_java_lang_ClassLoader);
@@ -866,12 +887,12 @@ classinfo *load_class_from_sysloader(utf *name)
 
 *******************************************************************************/
 
-classinfo *load_class_from_classloader(utf *name, java_objectheader *cl)
+classinfo *load_class_from_classloader(utf *name, classloader *cl)
 {
-       java_objectheader *o;
-       classinfo         *c;
-       classinfo         *tmpc;
-       java_objectheader *string;
+       java_handle_t *o;
+       classinfo     *c;
+       classinfo     *tmpc;
+       java_handle_t *string;
 #if defined(ENABLE_RT_TIMING)
        struct timespec time_start, time_lookup, time_prepare, time_java, 
                                        time_cache;
@@ -985,7 +1006,7 @@ classinfo *load_class_from_classloader(utf *name, java_objectheader *cl)
 
                RT_TIMING_GET_TIME(time_java);
 
-               c = (classinfo *) o;
+               c = LLNI_classinfo_unwrap(o);
 
                if (c != NULL) {
                        /* Store this class in the loaded class cache. If another
@@ -1400,16 +1421,14 @@ classinfo *load_class_from_classbuffer(classbuffer *cb)
        RT_TIMING_GET_TIME(time_setup);
 
        /* load fields */
+
        if (!suck_check_classbuffer_size(cb, 2))
                goto return_exception;
 
        c->fieldscount = suck_u2(cb);
-#if defined(ENABLE_GC_CACAO)
-       c->fields = MNEW(fieldinfo, c->fieldscount);
+       c->fields      = MNEW(fieldinfo, c->fieldscount);
+
        MZERO(c->fields, fieldinfo, c->fieldscount);
-#else
-       c->fields = GCNEW_UNCOLLECTABLE(fieldinfo, c->fieldscount);
-#endif
 
        for (i = 0; i < c->fieldscount; i++) {
                if (!field_load(cb, &(c->fields[i]), descpool))
@@ -1419,11 +1438,12 @@ classinfo *load_class_from_classbuffer(classbuffer *cb)
        RT_TIMING_GET_TIME(time_fields);
 
        /* load methods */
+
        if (!suck_check_classbuffer_size(cb, 2))
                goto return_exception;
 
        c->methodscount = suck_u2(cb);
-       c->methods = MNEW(methodinfo, c->methodscount);
+       c->methods      = MNEW(methodinfo, c->methodscount);
 
        MZERO(c->methods, methodinfo, c->methodscount);
        
@@ -1760,7 +1780,7 @@ return_exception:
 
 *******************************************************************************/
 
-classinfo *load_newly_created_array(classinfo *c, java_objectheader *loader)
+classinfo *load_newly_created_array(classinfo *c, classloader *loader)
 {
        classinfo         *comp = NULL;
        methodinfo        *clone;