* ICMD_INLINE_START: -si display reformatted
[cacao.git] / src / vm / loader.c
index a5e3ba24c537163f1a8cf84a2f2e110bb8ae37d5..1b0ce1614e93e82cdd33bae92aa95d9ed382055b 100644 (file)
             Edwin Steiner
             Christian Thalinger
 
-   $Id: loader.c 2278 2005-04-12 19:49:45Z twisti $
+   $Id: loader.c 2996 2005-07-12 01:42:38Z michi $
 
 */
 
-
 #include <stdlib.h>
 #include <string.h>
 #include <assert.h>
@@ -76,7 +75,6 @@
 #include "vm/jit/asmpart.h"
 #include "vm/jit/codegen.inc.h"
 
-
 /******************************************************************************/
 /* DEBUG HELPERS                                                              */
 /******************************************************************************/
@@ -99,7 +97,7 @@
 
 #ifdef LOADER_VERBOSE
 static int loader_recursion = 0;
-#define LOADER_INDENT()   do { int i; for(i=0;i<loader_recursion;++i) fputs("    ",stderr); } while (0)
+#define LOADER_INDENT(str)   do { int i; for(i=0;i<loader_recursion*4;++i) {str[i]=' ';} str[i]=0;} while (0)
 #define LOADER_INC()  loader_recursion++
 #define LOADER_DEC()  loader_recursion--
 #else
@@ -115,6 +113,7 @@ static int loader_recursion = 0;
 
 classpath_info *classpath_entries = NULL;
 
+
 /* loader_init *****************************************************************
 
    Initializes all lists and loads all classes required for the system
@@ -124,9 +123,9 @@ classpath_info *classpath_entries = NULL;
  
 bool loader_init(u1 *stackbottom)
 {
+#if defined(USE_THREADS) && defined(NATIVE_THREADS)
        classpath_info *cpi;
 
-#if defined(USE_THREADS) && defined(NATIVE_THREADS)
        /* Initialize the monitor pointer for zip/jar file locking.               */
 
        for (cpi = classpath_entries; cpi != NULL; cpi = cpi->next) {
@@ -137,65 +136,102 @@ bool loader_init(u1 *stackbottom)
 
        /* load some important classes */
 
-       if (!load_class_bootstrap(utf_java_lang_Object, &class_java_lang_Object))
+       if (!(class_java_lang_Object = load_class_bootstrap(utf_java_lang_Object)))
                return false;
 
-       if (!load_class_bootstrap(utf_java_lang_String, &class_java_lang_String))
+       if (!(class_java_lang_String = load_class_bootstrap(utf_java_lang_String)))
                return false;
 
-       if (!load_class_bootstrap(utf_java_lang_Cloneable, &class_java_lang_Cloneable))
+       if (!(class_java_lang_Cloneable =
+                 load_class_bootstrap(utf_java_lang_Cloneable)))
                return false;
 
-       if (!load_class_bootstrap(utf_java_io_Serializable, &class_java_io_Serializable))
+       if (!(class_java_io_Serializable =
+                 load_class_bootstrap(utf_java_io_Serializable)))
                return false;
 
 
        /* load classes for wrapping primitive types */
 
-       if (!load_class_bootstrap(utf_java_lang_Void, &class_java_lang_Void))
+       if (!(class_java_lang_Void = load_class_bootstrap(utf_java_lang_Void)))
                return false;
 
-       if (!load_class_bootstrap(utf_java_lang_Boolean, &class_java_lang_Boolean))
+       if (!(class_java_lang_Boolean =
+                 load_class_bootstrap(utf_java_lang_Boolean)))
                return false;
 
-       if (!load_class_bootstrap(utf_java_lang_Byte, &class_java_lang_Byte))
+       if (!(class_java_lang_Byte = load_class_bootstrap(utf_java_lang_Byte)))
                return false;
 
-       if (!load_class_bootstrap(utf_java_lang_Character, &class_java_lang_Character))
+       if (!(class_java_lang_Character =
+                 load_class_bootstrap(utf_java_lang_Character)))
                return false;
 
-       if (!load_class_bootstrap(utf_java_lang_Short, &class_java_lang_Short))
+       if (!(class_java_lang_Short = load_class_bootstrap(utf_java_lang_Short)))
                return false;
 
-       if (!load_class_bootstrap(utf_java_lang_Integer, &class_java_lang_Integer))
+       if (!(class_java_lang_Integer =
+                 load_class_bootstrap(utf_java_lang_Integer)))
                return false;
 
-       if (!load_class_bootstrap(utf_java_lang_Long, &class_java_lang_Long))
+       if (!(class_java_lang_Long = load_class_bootstrap(utf_java_lang_Long)))
                return false;
 
-       if (!load_class_bootstrap(utf_java_lang_Float, &class_java_lang_Float))
+       if (!(class_java_lang_Float = load_class_bootstrap(utf_java_lang_Float)))
                return false;
 
-       if (!load_class_bootstrap(utf_java_lang_Double, &class_java_lang_Double))
+       if (!(class_java_lang_Double = load_class_bootstrap(utf_java_lang_Double)))
                return false;
 
 
        /* load some other important classes */
 
-       if (!load_class_bootstrap(utf_java_lang_Class, &class_java_lang_Class))
+       if (!(class_java_lang_Class = load_class_bootstrap(utf_java_lang_Class)))
+               return false;
+
+       if (!(class_java_lang_ClassLoader =
+                 load_class_bootstrap(utf_java_lang_ClassLoader)))
                return false;
 
-       if (!load_class_bootstrap(utf_java_lang_ClassLoader, &class_java_lang_ClassLoader))
+       if (!(class_java_lang_SecurityManager =
+                 load_class_bootstrap(utf_java_lang_SecurityManager)))
                return false;
 
-       if (!load_class_bootstrap(utf_java_lang_SecurityManager, &class_java_lang_SecurityManager))
+       if (!(class_java_lang_System = load_class_bootstrap(utf_java_lang_System)))
                return false;
 
-       if (!load_class_bootstrap(utf_java_lang_System, &class_java_lang_System))
+       if (!(class_java_lang_ThreadGroup =
+                 load_class_bootstrap(utf_java_lang_ThreadGroup)))
                return false;
 
 
-       if (!load_class_bootstrap(utf_java_util_Vector, &class_java_util_Vector))
+       /* some classes which may be used more often */
+
+       if (!(class_java_lang_StackTraceElement =
+                 load_class_bootstrap(utf_java_lang_StackTraceElement)))
+               return false;
+
+       if (!(class_java_lang_reflect_Constructor =
+                 load_class_bootstrap(utf_java_lang_reflect_Constructor)))
+               return false;
+
+       if (!(class_java_lang_reflect_Field =
+                 load_class_bootstrap(utf_java_lang_reflect_Field)))
+               return false;
+
+       if (!(class_java_lang_reflect_Method =
+                 load_class_bootstrap(utf_java_lang_reflect_Method)))
+               return false;
+
+       if (!(class_java_security_PrivilegedAction =
+                 load_class_bootstrap(utf_new_char("java/security/PrivilegedAction"))))
+               return false;
+
+       if (!(class_java_util_Vector = load_class_bootstrap(utf_java_util_Vector)))
+               return false;
+
+       if (!(arrayclass_java_lang_Object =
+                 load_class_bootstrap(utf_new_char("[Ljava/lang/Object;"))))
                return false;
 
 #if defined(USE_THREADS)
@@ -486,10 +522,16 @@ void suck_init(char *classpath)
 }
 
 
-void create_all_classes()
+/* loader_load_all_classes *****************************************************
+
+   Loads all classes specified in the BOOTCLASSPATH.
+
+*******************************************************************************/
+
+void loader_load_all_classes(void)
 {
        classpath_info *cpi;
-       classinfo *c;
+       classinfo      *c;
 
        for (cpi = classpath_entries; cpi != 0; cpi = cpi->next) {
 #if defined(USE_ZLIB)
@@ -501,7 +543,12 @@ void create_all_classes()
                        ce = s->cacao_dir_list;
                                
                        while (ce) {
-                               load_class_bootstrap(ce->name,&c);
+                               /* skip all entries in META-INF and .properties files */
+
+                               if (strncmp(ce->name->text, "META-INF", strlen("META-INF")) &&
+                                       !strstr(ce->name->text, ".properties"))
+                                       c = load_class_bootstrap(ce->name);
+
                                ce = ce->next;
                        }
 
@@ -634,9 +681,17 @@ classbuffer *suck_start(classinfo *c)
        }
 
        if (opt_verbose)
-               if (!found)
+               if (!found) {
                        dolog("Warning: Can not open class file '%s'", filename);
 
+                       if (strcmp(filename, "org/mortbay/util/MultiException.class") == 0) {
+                               static int i = 0;
+                               i++;
+                               if (i == 3)
+                                       assert(0);
+                       }
+               }
+
        MFREE(filename, char, filenamelen);
 
        return cb;
@@ -749,7 +804,7 @@ static bool skipattributes(classbuffer *cb, u4 num)
 
 *******************************************************************************/
 
-static bool load_constantpool(classbuffer *cb,descriptor_pool *descpool)
+static bool load_constantpool(classbuffer *cb, descriptor_pool *descpool)
 {
 
        /* The following structures are used to save information which cannot be 
@@ -1031,7 +1086,7 @@ static bool load_constantpool(classbuffer *cb,descriptor_pool *descpool)
                                !is_valid_utf((char *) (cb->pos + 1),
                                                          (char *) (cb->pos + 1 + length))) {
                                dolog("Invalid UTF-8 string (constant pool index %d)",idx);
-                               panic("Invalid UTF-8 string");
+                               assert(0);
                        }
                        /* insert utf-string into the utf-symboltable */
                        cpinfos[idx] = utf_new_intern((char *) (cb->pos + 1), length);
@@ -1049,18 +1104,6 @@ static bool load_constantpool(classbuffer *cb,descriptor_pool *descpool)
                }  /* end switch */
        } /* end while */
 
-       /* add all class references to the descriptor_pool */
-       for (nfc=forward_classes; nfc; nfc=nfc->next) {
-               utf *name = class_getconstant(c,nfc->name_index,CONSTANT_Utf8);
-               if (!descriptor_pool_add_class(descpool,name))
-                       return false;
-       }
-       /* add all descriptors in NameAndTypes to the descriptor_pool */
-       for (nfn=forward_nameandtypes; nfn; nfn=nfn->next) {
-               utf *desc = class_getconstant(c,nfn->sig_index,CONSTANT_Utf8);
-               if (!descriptor_pool_add(descpool,desc,NULL))
-                       return false;
-       }
 
        /* resolve entries in temporary structures */
 
@@ -1074,7 +1117,24 @@ static bool load_constantpool(classbuffer *cb,descriptor_pool *descpool)
                        return false;
                }
 
+               /* add all class references to the descriptor_pool */
+
+               if (!descriptor_pool_add_class(descpool, name))
+                       return false;
+
                cptags[forward_classes->thisindex] = CONSTANT_Class;
+
+               if (opt_eager) {
+                       classinfo *tc;
+
+                       if (!(tc = load_class_bootstrap(name)))
+                               return false;
+
+                       /* link the class later, because we cannot link the class currently
+                          loading */
+                       list_addfirst(&unlinkedclasses, tc);
+               }
+
                /* the classref is created later */
                cpinfos[forward_classes->thisindex] = name;
 
@@ -1147,12 +1207,19 @@ static bool load_constantpool(classbuffer *cb,descriptor_pool *descpool)
                        count_const_pool_len += sizeof(constant_FMIref);
 #endif
                /* resolve simple name and descriptor */
+
                nat = class_getconstant(c,
                                                                forward_fieldmethints->nameandtype_index,
                                                                CONSTANT_NameAndType);
 
+               /* add all descriptors in {Field,Method}ref to the descriptor_pool */
+
+               if (!descriptor_pool_add(descpool, nat->descriptor, NULL))
+                       return false;
+
                /* the classref is created later */
-               fmi->classref = (constant_classref*) (size_t) forward_fieldmethints->class_index;
+
+               fmi->classref = (constant_classref *) (size_t) forward_fieldmethints->class_index;
                fmi->name = nat->name;
                fmi->descriptor = nat->descriptor;
 
@@ -1179,7 +1246,7 @@ static bool load_constantpool(classbuffer *cb,descriptor_pool *descpool)
 
 #define field_load_NOVALUE  0xffffffff /* must be bigger than any u2 value! */
 
-static bool load_field(classbuffer *cb, fieldinfo *f,descriptor_pool *descpool)
+static bool load_field(classbuffer *cb, fieldinfo *f, descriptor_pool *descpool)
 {
        classinfo *c;
        u4 attrnum, i;
@@ -1196,13 +1263,16 @@ static bool load_field(classbuffer *cb, fieldinfo *f,descriptor_pool *descpool)
 
        if (!(u = class_getconstant(c, suck_u2(cb), CONSTANT_Utf8)))
                return false;
+
        f->name = u;
 
        if (!(u = class_getconstant(c, suck_u2(cb), CONSTANT_Utf8)))
                return false;
+
        f->descriptor = u;
        f->parseddesc = NULL;
-       if (!descriptor_pool_add(descpool,u,NULL))
+
+       if (!descriptor_pool_add(descpool, u, NULL))
                return false;
 
        if (opt_verify) {
@@ -1367,7 +1437,7 @@ static bool load_field(classbuffer *cb, fieldinfo *f,descriptor_pool *descpool)
        
 *******************************************************************************/
 
-static bool load_method(classbuffer *cb, methodinfo *m,descriptor_pool *descpool)
+static bool load_method(classbuffer *cb, methodinfo *m, descriptor_pool *descpool)
 {
        classinfo *c;
        int argcount;
@@ -1400,22 +1470,29 @@ static bool load_method(classbuffer *cb, methodinfo *m,descriptor_pool *descpool
 
        if (!(u = class_getconstant(c, suck_u2(cb), CONSTANT_Utf8)))
                return false;
+
        m->name = u;
 
        if (!(u = class_getconstant(c, suck_u2(cb), CONSTANT_Utf8)))
                return false;
+
        m->descriptor = u;
        m->parseddesc = NULL;
-       if (!descriptor_pool_add(descpool,u,&argcount))
+
+       if (!descriptor_pool_add(descpool, u, &argcount))
                return false;
 
        if (opt_verify) {
-               if (!is_valid_name_utf(m->name))
-                       panic("Method with invalid name");
+               if (!is_valid_name_utf(m->name)) {
+                       log_text("Method with invalid name");
+                       assert(0);
+               }
 
-               if (m->name->text[0] == '<'
-                       && m->name != utf_init && m->name != utf_clinit)
-                       panic("Method with invalid special name");
+               if (m->name->text[0] == '<' &&
+                       m->name != utf_init && m->name != utf_clinit) {
+                       log_text("Method with invalid special name");
+                       assert(0);
+               }
        }
        
        if (!(m->flags & ACC_STATIC))
@@ -1463,8 +1540,10 @@ static bool load_method(classbuffer *cb, methodinfo *m,descriptor_pool *descpool
 
                        if (m->name == utf_init) {
                                if (m->flags & (ACC_STATIC | ACC_FINAL | ACC_SYNCHRONIZED |
-                                                               ACC_NATIVE | ACC_ABSTRACT))
-                                       panic("Instance initialization method has invalid flags set");
+                                                               ACC_NATIVE | ACC_ABSTRACT)) {
+                                       log_text("Instance initialization method has invalid flags set");
+                                       assert(0);
+                               }
                        }
                }
        }
@@ -1774,33 +1853,32 @@ static bool load_attributes(classbuffer *cb, u4 num)
        return true;
 }
 
+
 /* load_class_from_sysloader ***************************************************
 
    Load the class with the given name using the system class loader
 
    IN:
        name.............the classname
-          
-
-   OUT:
-       *result..........set to the loaded class
 
    RETURN VALUE:
-       true.............everything ok
-          false............an exception has been thrown
+       the loaded class, or
+          NULL if an exception has been thrown
 
 *******************************************************************************/
 
-bool load_class_from_sysloader(utf *name,classinfo **result)
+classinfo *load_class_from_sysloader(utf *name)
 {
-       methodinfo *m;
+       methodinfo        *m;
        java_objectheader *cl;
-       bool success;
+       classinfo         *r;
 
 #ifdef LOADER_VERBOSE
-       LOADER_INDENT();
-       fprintf(stderr,"load_class_from_sysloader(");
-       utf_fprint(stderr,name);fprintf(stderr,")\n");
+       char logtext[MAXLOGTEXT];
+       LOADER_INDENT(logtext);
+       sprintf(logtext+strlen(logtext),"load_class_from_sysloader(");
+       utf_sprint(logtext+strlen(logtext),name);strcat(logtext,")");
+       log_text(logtext);
 #endif
 
        LOADER_ASSERT(class_java_lang_Object);
@@ -1808,22 +1886,23 @@ bool load_class_from_sysloader(utf *name,classinfo **result)
        LOADER_ASSERT(class_java_lang_ClassLoader->linked);
        
        m = class_resolveclassmethod(class_java_lang_ClassLoader,
-                                                                utf_new_char("getSystemClassLoader"), /* XXX use variable */
-                                                                utf_new_char("()Ljava/lang/ClassLoader;"), /* XXX use variable */
+                                                                utf_getSystemClassLoader,
+                                                                utf_void__java_lang_ClassLoader,
                                                                 class_java_lang_Object,
                                                                 false);
 
        if (!m)
-               return false; /* exception */
+               return false;
 
        cl = (java_objectheader *) asm_calljavafunction(m, NULL, NULL, NULL, NULL);
        if (!cl)
-               return false; /* exception */
+               return false;
 
        LOADER_INC();
-       success = load_class_from_classloader(name,cl,result);
+       r = load_class_from_classloader(name, cl);
        LOADER_DEC();
-       return success;
+
+       return r;
 }
 
 /* load_class_from_classloader *************************************************
@@ -1834,39 +1913,41 @@ bool load_class_from_sysloader(utf *name,classinfo **result)
        name.............the classname
           cl...............user-defined class loader
           
-
-   OUT:
-       *result..........set to the loaded class
-
    RETURN VALUE:
-       true.............everything ok
-          false............an exception has been thrown
+       the loaded class, or
+          NULL if an exception has been thrown
 
 *******************************************************************************/
 
-bool load_class_from_classloader(utf *name,java_objectheader *cl,classinfo **result)
+classinfo *load_class_from_classloader(utf *name, java_objectheader *cl)
 {
        classinfo *r;
-       bool success;
-
-       LOADER_ASSERT(name);
-       LOADER_ASSERT(result);
 
 #ifdef LOADER_VERBOSE
-       LOADER_INDENT();
-       fprintf(stderr,"load_class_from_classloader(");
-       utf_fprint(stderr,name);fprintf(stderr,",%p)\n",(void*)cl);
+       char logtext[MAXLOGTEXT];
+       LOADER_INDENT(logtext);
+       strcat(logtext,"load_class_from_classloader(");
+       utf_sprint(logtext+strlen(logtext),name);sprintf(logtext+strlen(logtext),",%p,",(void*)cl);
+       if (!cl) strcat(logtext,"<bootstrap>");
+       else if (cl->vftbl && cl->vftbl->class) utf_sprint(logtext+strlen(logtext),cl->vftbl->class->name);
+       else strcat(logtext,"<unknown class>");
+       strcat(logtext,")");
+       log_text(logtext);
 #endif
 
+       LOADER_ASSERT(name);
+
        /* lookup if this class has already been loaded */
-       *result = classcache_lookup(cl,name);
+
+       r = classcache_lookup(cl, name);
+
 #ifdef LOADER_VERBOSE
-       if (*result)
-               fprintf(stderr,"        cached -> %p\n",(void*)(*result));
+       if (r)
+               dolog("        cached -> %p",(void*)r);
 #endif
 
-       if (*result)
-               return true;
+       if (r)
+               return r;
 
        /* if other class loader than bootstrap, call it */
 
@@ -1875,32 +1956,38 @@ bool load_class_from_classloader(utf *name,java_objectheader *cl,classinfo **res
 
                /* handle array classes */
                if (name->text[0] == '[') {
-                       char *utf_ptr = name->text + 1;
-                       int len = name->blength - 1;
+                       char      *utf_ptr;
+                       s4         len;
                        classinfo *comp;
+                       utf       *u;
+
+                       utf_ptr = name->text + 1;
+                       len = name->blength - 1;
+
                        switch (*utf_ptr) {
-                               case 'L':
-                                       utf_ptr++;
-                                       len -= 2;
-                                       /* FALLTHROUGH */
-                               case '[':
-                                       /* load the component class */
-                                       LOADER_INC();
-                                       if (!load_class_from_classloader(utf_new(utf_ptr,len),cl,&comp)) {
-                                               LOADER_DEC();
-                                               return false;
-                                       }
+                       case 'L':
+                               utf_ptr++;
+                               len -= 2;
+                               /* FALLTHROUGH */
+                       case '[':
+                               /* load the component class */
+                               u = utf_new(utf_ptr, len);
+                               LOADER_INC();
+                               if (!(comp = load_class_from_classloader(u, cl))) {
                                        LOADER_DEC();
-                                       /* create the array class */
-                                       *result = class_array_of(comp,false);
-                                       return (*result != 0);
-                                       break;
-                               default:
-                                       /* primitive array classes are loaded by the bootstrap loader */
-                                       LOADER_INC();
-                                       success = load_class_bootstrap(name,result);
-                                       LOADER_DEC();
-                                       return success;
+                                       return false;
+                               }
+                               LOADER_DEC();
+                               /* create the array class */
+                               r = class_array_of(comp, false);
+                               return r;
+                               break;
+                       default:
+                               /* primitive array classes are loaded by the bootstrap loader */
+                               LOADER_INC();
+                               r = load_class_bootstrap(name);
+                               LOADER_DEC();
+                               return r;
                        }
                }
                
@@ -1918,25 +2005,34 @@ bool load_class_from_classloader(utf *name,java_objectheader *cl,classinfo **res
                LOADER_INC();
                r = (classinfo *) asm_calljavafunction(lc,
                                                                                           cl,
-                                                                                          javastring_new(name),
+                                                                                          javastring_new_slash_to_dot(name),
                                                                                           NULL, NULL);
                LOADER_DEC();
 
-               /* store this class in the loaded class cache */
-               if (r && !classcache_store(cl,r)) {
-                       r->loaded = false;
-                       class_free(r);
-                       r = NULL; /* exception */
+               if (r) {
+                       /* store this class in the loaded class cache */
+                       /* If another class with the same (initloader,name) pair has been */
+                       /* stored earlier it will be returned by classcache_store         */
+                       /* In this case classcache_store may not free the class because it*/
+                       /* has already been exposed to Java code which may have kept      */
+                       /* references to that class.                                      */
+                   classinfo *c = classcache_store(cl,r,false);
+                       if (c == NULL) {
+                               /* exception, free the loaded class */
+                               r->loaded = false;
+                               class_free(r);
+                       }
+                       r = c;
                }
 
-               *result = r;
-               return (r != NULL);
+               return r;
        } 
 
        LOADER_INC();
-       success = load_class_bootstrap(name,result);
+       r = load_class_bootstrap(name);
        LOADER_DEC();
-       return success;
+
+       return r;
 }
 
 
@@ -1947,62 +2043,60 @@ bool load_class_from_classloader(utf *name,java_objectheader *cl,classinfo **res
    IN:
        name.............the classname
 
-   OUT:
-       *result..........set to the loaded class
-
    RETURN VALUE:
-       true.............everything ok
-          false............an exception has been thrown
+       loaded classinfo, or
+          NULL if an exception has been thrown
+
+   SYNCHRONIZATION:
+       load_class_bootstrap is synchronized. It can be treated as an
+          atomic operation.
 
 *******************************************************************************/
 
-bool load_class_bootstrap(utf *name, classinfo **result)
+classinfo *load_class_bootstrap(utf *name)
 {
        classbuffer *cb;
-       classinfo *c;
-       classinfo *r;
+       classinfo   *c;
+       classinfo   *r;
+#ifdef LOADER_VERBOSE
+       char logtext[MAXLOGTEXT];
+#endif
+
+       /* for debugging */
 
        LOADER_ASSERT(name);
-       LOADER_ASSERT(result);
+       LOADER_INC();
 
        /* lookup if this class has already been loaded */
-       *result = classcache_lookup(NULL, name);
-       if (*result)
-               return true;
 
-       /* check if this class has already been defined */
-       *result = classcache_lookup_defined(NULL, name);
-       if (*result)
-               return true;
+       if ((r = classcache_lookup(NULL, name)))
+               goto success;
 
 #ifdef LOADER_VERBOSE
-       LOADER_INDENT();
-       fprintf(stderr,"load_class_bootstrap(");
-       utf_fprint(stderr,name);fprintf(stderr,")\n");
+       LOADER_INDENT(logtext);
+       strcat(logtext,"load_class_bootstrap(");
+       utf_sprint(logtext+strlen(logtext),name);strcat(logtext,")");
+       log_text(logtext);
 #endif
 
        /* create the classinfo */
+
        c = class_create_classinfo(name);
        
        /* handle array classes */
+
        if (name->text[0] == '[') {
-               LOADER_INC();
-               if (!load_newly_created_array(c, NULL))
-                       return false;
-               LOADER_DEC();
+               c = load_newly_created_array(c, NULL);
+               if (c == NULL)
+                       goto return_exception;
                LOADER_ASSERT(c->loaded);
-               *result = c;
-               return true;
+               r = c;
+               goto success;
        }
 
-#if defined(USE_THREADS)
-       /* enter a monitor on the class */
-
-       builtin_monitorenter((java_objectheader *) c);
-#endif
-
 #if defined(STATISTICS)
        /* measure time */
+
        if (getcompilingtime)
                compilingtime_stop();
 
@@ -2013,7 +2107,8 @@ bool load_class_bootstrap(utf *name, classinfo **result)
        /* load classdata, throw exception on error */
 
        if ((cb = suck_start(c)) == NULL) {
-               /* this means, the classpath was not set properly */
+               /* this normally means, the classpath was not set properly */
+
                if (name == utf_java_lang_Object)
                        throw_cacao_exception_exit(string_java_lang_NoClassDefFoundError,
                                                                           "java/lang/Object");
@@ -2021,25 +2116,20 @@ bool load_class_bootstrap(utf *name, classinfo **result)
                *exceptionptr =
                        new_exception_utfmessage(string_java_lang_NoClassDefFoundError,
                                                                         name);
-
-#if defined(USE_THREADS)
-               builtin_monitorexit((java_objectheader *) c);
-#endif
-
-               return false;
+               goto return_exception;
        }
        
        /* load the class from the buffer */
 
-       LOADER_INC();
        r = load_class_from_classbuffer(cb);
-       LOADER_DEC();
 
        /* free memory */
+
        suck_stop(cb);
 
 #if defined(STATISTICS)
        /* measure time */
+
        if (getloadingtime)
                loadingtime_stop();
 
@@ -2048,28 +2138,35 @@ bool load_class_bootstrap(utf *name, classinfo **result)
 #endif
 
        if (!r) {
-#if defined(USE_THREADS)
-               builtin_monitorexit((java_objectheader *) c);
-#endif
-               class_free(c);
-       }
+               /* the class could not be loaded, free the classinfo struct */
 
-       /* store this class in the loaded class cache */
-       if (r && !classcache_store(NULL, c)) {
-#if defined(USE_THREADS)
-               builtin_monitorexit((java_objectheader *) c);
-#endif
                class_free(c);
-               r = NULL; /* exception */
+       }
+       else {
+               /* store this class in the loaded class cache    */
+               /* this step also checks the loading constraints */
+               /* If the class has been loaded before, the      */
+               /* earlier loaded class is returned.             */
+               classinfo *res = classcache_store(NULL,c,true);
+               if (!res) {
+                       /* exception */
+                       class_free(c);
+               }
+               r = res;
        }
 
-#if defined(USE_THREADS)
-       /* leave the monitor */
-       if (c) builtin_monitorexit((java_objectheader *) c);
-#endif
+       if (!r)
+               goto return_exception;
 
-       *result = r;
-       return (r != NULL);
+success:
+       LOADER_DEC();
+
+       return r;
+
+return_exception:
+       LOADER_DEC();
+
+       return NULL;
 }
 
 
@@ -2084,6 +2181,9 @@ bool load_class_bootstrap(utf *name, classinfo **result)
    The loaded class is removed from the list 'unloadedclasses' and
    added to the list 'unlinkedclasses'.
        
+   SYNCHRONIZATION:
+       This function is NOT synchronized!
+   
 *******************************************************************************/
 
 classinfo *load_class_from_classbuffer(classbuffer *cb)
@@ -2095,23 +2195,28 @@ classinfo *load_class_from_classbuffer(classbuffer *cb)
        u4 ma, mi;
        s4 dumpsize;
        descriptor_pool *descpool;
-       char msg[MAXLOGTEXT];               /* maybe we get an exception */
 #if defined(STATISTICS)
        u4 classrefsize;
        u4 descsize;
 #endif
+#ifdef LOADER_VERBOSE
+       char logtext[MAXLOGTEXT];
+#endif
 
        /* get the classbuffer's class */
+
        c = cb->class;
 
        /* maybe the class is already loaded */
+
        if (c->loaded)
                return c;
 
 #ifdef LOADER_VERBOSE
-       LOADER_INDENT();
-       fprintf(stderr,"load_class_from_classbuffer(");
-       utf_fprint(stderr,c->name);fprintf(stderr,")\n");
+       LOADER_INDENT(logtext);
+       strcat(logtext,"load_class_from_classbuffer(");
+       utf_sprint(logtext+strlen(logtext),c->name);strcat(logtext,")");
+       log_text(logtext);
        LOADER_INC();
 #endif
 
@@ -2121,19 +2226,23 @@ classinfo *load_class_from_classbuffer(classbuffer *cb)
 #endif
 
        /* output for debugging purposes */
+
        if (loadverbose)
                log_message_class("Loading class: ", c);
        
        /* mark start of dump memory area */
+
        dumpsize = dump_size();
 
        /* class is somewhat loaded */
+
        c->loaded = true;
 
        if (!check_classbuffer_size(cb, 4 + 2 + 2))
                goto return_exception;
 
        /* check signature */
+
        if (suck_u4(cb) != MAGIC) {
                *exceptionptr = new_classformaterror(c, "Bad magic number");
 
@@ -2141,6 +2250,7 @@ classinfo *load_class_from_classbuffer(classbuffer *cb)
        }
 
        /* check version */
+
        mi = suck_u2(cb);
        ma = suck_u2(cb);
 
@@ -2154,10 +2264,12 @@ classinfo *load_class_from_classbuffer(classbuffer *cb)
        }
 
        /* create a new descriptor pool */
+
        descpool = descriptor_pool_new(c);
-       
+
        /* load the constant pool */
-       if (!load_constantpool(cb,descpool))
+
+       if (!load_constantpool(cb, descpool))
                goto return_exception;
 
        /*JOWENN*/
@@ -2168,12 +2280,14 @@ classinfo *load_class_from_classbuffer(classbuffer *cb)
        c->impldBy = NULL;
 
        /* ACC flags */
+
        if (!check_classbuffer_size(cb, 2))
                goto return_exception;
 
        c->flags = suck_u2(cb);
 
        /* check ACC flags consistency */
+
        if (c->flags & ACC_INTERFACE) {
                if (!(c->flags & ACC_ABSTRACT)) {
                        /* We work around this because interfaces in JDK 1.1 are
@@ -2206,11 +2320,25 @@ classinfo *load_class_from_classbuffer(classbuffer *cb)
                goto return_exception;
 
        /* this class */
+
        i = suck_u2(cb);
        if (!(name = (utf *) class_getconstant(c, i, CONSTANT_Class)))
                goto return_exception;
 
-       if (name != c->name) {
+       if (c->name == utf_not_named_yet) {
+               /* we finally have a name for this class */
+               c->name = name;
+               class_set_packagename(c);
+
+       } else if (name != c->name) {
+               char *msg;
+               s4    msglen;
+
+               msglen = utf_strlen(c->name) + strlen(" (wrong name: ") +
+                       utf_strlen(name) + strlen(")") + strlen("0");
+
+               msg = MNEW(char, msglen);
+
                utf_sprint(msg, c->name);
                strcat(msg, " (wrong name: ");
                utf_strcat(msg, name);
@@ -2219,16 +2347,20 @@ classinfo *load_class_from_classbuffer(classbuffer *cb)
                *exceptionptr =
                        new_exception_message(string_java_lang_NoClassDefFoundError, msg);
 
+               MFREE(msg, char, msglen);
+
                goto return_exception;
        }
        
        /* retrieve superclass */
+
        c->super.any = NULL;
        if ((i = suck_u2(cb))) {
                if (!(supername = (utf *) class_getconstant(c, i, CONSTANT_Class)))
                        goto return_exception;
 
                /* java.lang.Object may not have a super class. */
+
                if (c->name == utf_java_lang_Object) {
                        *exceptionptr =
                                new_exception_message(string_java_lang_ClassFormatError,
@@ -2238,6 +2370,7 @@ classinfo *load_class_from_classbuffer(classbuffer *cb)
                }
 
                /* Interfaces must have java.lang.Object as super class. */
+
                if ((c->flags & ACC_INTERFACE) &&
                        supername != utf_java_lang_Object) {
                        *exceptionptr =
@@ -2251,6 +2384,7 @@ classinfo *load_class_from_classbuffer(classbuffer *cb)
                supername = NULL;
 
                /* This is only allowed for java.lang.Object. */
+
                if (c->name != utf_java_lang_Object) {
                        *exceptionptr = new_classformaterror(c, "Bad superclass index");
 
@@ -2259,6 +2393,7 @@ classinfo *load_class_from_classbuffer(classbuffer *cb)
        }
                         
        /* retrieve interfaces */
+
        if (!check_classbuffer_size(cb, 2))
                goto return_exception;
 
@@ -2299,15 +2434,19 @@ classinfo *load_class_from_classbuffer(classbuffer *cb)
        }
 
        /* create the class reference table */
-       c->classrefs = descriptor_pool_create_classrefs(descpool,&(c->classrefcount));
+
+       c->classrefs =
+               descriptor_pool_create_classrefs(descpool, &(c->classrefcount));
 
        /* allocate space for the parsed descriptors */
+
        descriptor_pool_alloc_parsed_descriptors(descpool);
-       c->parseddescs = descriptor_pool_get_parsed_descriptors(descpool,&(c->parseddescsize));
+       c->parseddescs =
+               descriptor_pool_get_parsed_descriptors(descpool, &(c->parseddescsize));
 
 #if defined(STATISTICS)
        if (opt_stat) {
-               descriptor_pool_get_sizes(descpool,&classrefsize,&descsize);
+               descriptor_pool_get_sizes(descpool, &classrefsize, &descsize);
                count_classref_len += classrefsize;
                count_parsed_desc_len += descsize;
        }
@@ -2322,6 +2461,7 @@ classinfo *load_class_from_classbuffer(classbuffer *cb)
        }
 
        /* set the super class reference */
+
        if (supername) {
                c->super.ref = descriptor_pool_lookup_classref(descpool, supername);
                if (!c->super.ref)
@@ -2329,53 +2469,32 @@ classinfo *load_class_from_classbuffer(classbuffer *cb)
        }
 
        /* set the super interfaces references */
+
        for (i = 0; i < c->interfacescount; i++) {
-               c->interfaces[i].ref = descriptor_pool_lookup_classref(descpool, (utf *) c->interfaces[i].any);
+               c->interfaces[i].ref =
+                       descriptor_pool_lookup_classref(descpool,
+                                                                                       (utf *) c->interfaces[i].any);
                if (!c->interfaces[i].ref)
                        goto return_exception;
        }
 
-       /* parse the loaded descriptors */
-       for (i = 0; i < c->cpcount; i++) {
-               constant_FMIref *fmi;
-               int index;
-               
-               switch (c->cptags[i]) {
-                       case CONSTANT_Fieldref:
-                               fmi = (constant_FMIref *) c->cpinfos[i];
-                               fmi->parseddesc.fd = 
-                                       descriptor_pool_parse_field_descriptor(descpool, fmi->descriptor);
-                               if (!fmi->parseddesc.fd)
-                                       goto return_exception;
-                               index = (int) (size_t) fmi->classref;
-                               fmi->classref = (constant_classref *) class_getconstant(c, index, CONSTANT_Class);
-                               if (!fmi->classref)
-                                       goto return_exception;
-                               break;
-                       case CONSTANT_Methodref:
-                       case CONSTANT_InterfaceMethodref:
-                               fmi = (constant_FMIref *) c->cpinfos[i];
-                               fmi->parseddesc.md = 
-                                       descriptor_pool_parse_method_descriptor(descpool, fmi->descriptor);
-                               if (!fmi->parseddesc.md)
-                                       goto return_exception;
-                               index = (int) (size_t) fmi->classref;
-                               fmi->classref = (constant_classref *) class_getconstant(c, index, CONSTANT_Class);
-                               if (!fmi->classref)
-                                       goto return_exception;
-                               break;
-               }
-       }
+       /* parse field descriptors */
 
        for (i = 0; i < c->fieldscount; i++) {
-               c->fields[i].parseddesc = descriptor_pool_parse_field_descriptor(descpool, c->fields[i].descriptor);
+               c->fields[i].parseddesc =
+                       descriptor_pool_parse_field_descriptor(descpool,
+                                                                                                  c->fields[i].descriptor);
                if (!c->fields[i].parseddesc)
                        goto return_exception;
        }
 
+       /* parse method descriptors */
+
        for (i = 0; i < c->methodscount; i++) {
-               methodinfo *m = c->methods + i;
-               m->parseddesc = descriptor_pool_parse_method_descriptor(descpool, m->descriptor);
+               methodinfo *m = &c->methods[i];
+               m->parseddesc =
+                       descriptor_pool_parse_method_descriptor(descpool, m->descriptor,
+                                                                                                       m->flags, class_get_self_classref(m->class));
                if (!m->parseddesc)
                        goto return_exception;
 
@@ -2397,8 +2516,50 @@ classinfo *load_class_from_classbuffer(classbuffer *cb)
                }
        }
 
+       /* parse the loaded descriptors */
+
+       for (i = 0; i < c->cpcount; i++) {
+               constant_FMIref *fmi;
+               s4               index;
+               
+               switch (c->cptags[i]) {
+               case CONSTANT_Fieldref:
+                       fmi = (constant_FMIref *) c->cpinfos[i];
+                       fmi->parseddesc.fd =
+                               descriptor_pool_parse_field_descriptor(descpool,
+                                                                                                          fmi->descriptor);
+                       if (!fmi->parseddesc.fd)
+                               goto return_exception;
+                       index = (int) (size_t) fmi->classref;
+                       fmi->classref =
+                               (constant_classref *) class_getconstant(c, index,
+                                                                                                               CONSTANT_Class);
+                       if (!fmi->classref)
+                               goto return_exception;
+                       break;
+               case CONSTANT_Methodref:
+               case CONSTANT_InterfaceMethodref:
+                       fmi = (constant_FMIref *) c->cpinfos[i];
+                       index = (int) (size_t) fmi->classref;
+                       fmi->classref =
+                               (constant_classref *) class_getconstant(c, index,
+                                                                                                               CONSTANT_Class);
+                       if (!fmi->classref)
+                               goto return_exception;
+                       fmi->parseddesc.md =
+                               descriptor_pool_parse_method_descriptor(descpool,
+                                                                                                               fmi->descriptor,
+                                                                                                               ACC_UNDEF,
+                                                                                                               fmi->classref);
+                       if (!fmi->parseddesc.md)
+                               goto return_exception;
+                       break;
+               }
+       }
+
        /* Check if all fields and methods can be uniquely
         * identified by (name,descriptor). */
+
        if (opt_verify) {
                /* We use a hash table here to avoid making the
                 * average case quadratic in # of methods, fields.
@@ -2500,6 +2661,7 @@ classinfo *load_class_from_classbuffer(classbuffer *cb)
 #endif
 
        /* load attribute structures */
+
        if (!check_classbuffer_size(cb, 2))
                goto return_exception;
 
@@ -2524,6 +2686,7 @@ classinfo *load_class_from_classbuffer(classbuffer *cb)
 #endif
 
        /* release dump area */
+
        dump_release(dumpsize);
        
        if (loadverbose)
@@ -2534,18 +2697,25 @@ classinfo *load_class_from_classbuffer(classbuffer *cb)
 
 return_exception:
        /* release dump area */
+
        dump_release(dumpsize);
 
        /* an exception has been thrown */
+
        LOADER_DEC();
        return NULL;
 }
 
 
-
 /* load_newly_created_array ****************************************************
 
-    Load a newly created array class.
+   Load a newly created array class.
+
+       RETURN VALUE:
+           c....................the array class C has been loaded
+               other classinfo......the array class was found in the class cache, 
+                                    C has been freed
+           NULL.................an exception has been thrown
 
        Note:
                This is an internal function. Do not use it unless you know exactly
@@ -2555,46 +2725,49 @@ return_exception:
 
 *******************************************************************************/
 
-bool load_newly_created_array(classinfo *c,java_objectheader *loader)
+classinfo * load_newly_created_array(classinfo *c,java_objectheader *loader)
 {
-       classinfo *comp = NULL;
-       methodinfo *clone;
-       methoddesc *clonedesc;
+       classinfo         *comp = NULL;
+       methodinfo        *clone;
+       methoddesc        *clonedesc;
        constant_classref *classrefs;
-       int namelen;
+       s4                 namelen;
        java_objectheader *definingloader = NULL;
+       utf               *u;
 
 #ifdef LOADER_VERBOSE
-       LOADER_INDENT();
-       fprintf(stderr,"load_newly_created_array(");utf_fprint_classname(stderr,c->name);
-       fprintf(stderr,") loader=%p\n",loader);
+       char logtext[MAXLOGTEXT];
+       LOADER_INDENT(logtext);
+       strcat(logtext,"load_newly_created_array(");utf_sprint_classname(logtext+strlen(logtext),c->name);
+       sprintf(logtext+strlen(logtext),") loader=%p",loader);
+       log_text(logtext);
 #endif
 
        /* Check array class name */
+
        namelen = c->name->blength;
        if (namelen < 2 || c->name->text[0] != '[') {
                *exceptionptr = new_internalerror("Invalid array class name");
-               return false;
+               return NULL;
        }
 
        /* Check the component type */
+
        switch (c->name->text[1]) {
        case '[':
                /* c is an array of arrays. We have to create the component class. */
+
+               u = utf_new_intern(c->name->text + 1, namelen - 1);
                LOADER_INC();
-               if (!load_class_from_classloader(utf_new_intern(c->name->text + 1,
-                                                                                                               namelen - 1),
-                                                                                loader,
-                                                                                &comp)) 
-               {
+               if (!(comp = load_class_from_classloader(u, loader))) {
                        LOADER_DEC();
-                       return false;
+                       return NULL;
                }
                LOADER_DEC();
                LOADER_ASSERT(comp->loaded);
                if (opt_eager)
                        if (!link_class(c))
-                               return false;
+                               return NULL;
                definingloader = comp->classloader;
                break;
 
@@ -2602,23 +2775,21 @@ bool load_newly_created_array(classinfo *c,java_objectheader *loader)
                /* c is an array of objects. */
                if (namelen < 4 || c->name->text[namelen - 1] != ';') {
                        *exceptionptr = new_internalerror("Invalid array class name");
-                       return false;
+                       return NULL;
                }
 
+               u = utf_new_intern(c->name->text + 2, namelen - 3);
+
                LOADER_INC();
-               if (!load_class_from_classloader(utf_new_intern(c->name->text + 2,
-                                                                                                               namelen - 3),
-                                                                                loader,
-                                                                                &comp)) 
-               {
+               if (!(comp = load_class_from_classloader(u, loader))) {
                        LOADER_DEC();
-                       return false;
+                       return NULL;
                }
                LOADER_DEC();
                LOADER_ASSERT(comp->loaded);
                if (opt_eager)
                        if (!link_class(c))
-                               return false;
+                               return NULL;
                definingloader = comp->classloader;
                break;
        }
@@ -2628,6 +2799,7 @@ bool load_newly_created_array(classinfo *c,java_objectheader *loader)
        LOADER_ASSERT(class_java_io_Serializable);
 
        /* Setup the array class */
+
        c->super.cls = class_java_lang_Object;
        c->flags = ACC_PUBLIC | ACC_FINAL | ACC_ABSTRACT;
 
@@ -2655,29 +2827,40 @@ bool load_newly_created_array(classinfo *c,java_objectheader *loader)
        c->methodscount = 1;
        c->methods = MNEW(methodinfo, c->methodscount);
 
-       classrefs = MNEW(constant_classref,1);
-       CLASSREF_INIT(classrefs[0],c,utf_java_lang_Object);
+       classrefs = MNEW(constant_classref, 2);
+       CLASSREF_INIT(classrefs[0], c, c->name);
+       CLASSREF_INIT(classrefs[1], c, utf_java_lang_Object);
 
+       /* create descriptor for clone method */
+       /* we need one paramslot which is reserved for the 'this' parameter */
        clonedesc = NEW(methoddesc);
        clonedesc->returntype.type = TYPE_ADDRESS;
-       clonedesc->returntype.classref = classrefs;
+       clonedesc->returntype.classref = classrefs + 1;
        clonedesc->returntype.arraydim = 0;
        clonedesc->paramcount = 0;
        clonedesc->paramslots = 0;
+       clonedesc->paramtypes[0].classref = classrefs + 0;
+
+       /* parse the descriptor to get the register allocation */
+
+       if (!descriptor_params_from_paramtypes(clonedesc, ACC_NONE))
+               return false;
 
        clone = c->methods;
        MSET(clone, 0, methodinfo, 1);
        clone->flags = ACC_PUBLIC;
-       clone->name = utf_new_char("clone");
+       clone->name = utf_clone;
        clone->descriptor = utf_void__java_lang_Object;
        clone->parseddesc = clonedesc;
        clone->class = c;
-       clone->stubroutine = createnativestub((functionptr) &builtin_clone_array, clone);
+       clone->stubroutine =
+               codegen_createnativestub((functionptr) &builtin_clone_array, clone);
        clone->monoPoly = MONO;
 
        /* XXX: field: length? */
 
        /* array classes are not loaded from class files */
+
        c->loaded = true;
        c->parseddescs = (u1*) clonedesc;
        c->parseddescsize = sizeof(methodinfo);
@@ -2686,10 +2869,8 @@ bool load_newly_created_array(classinfo *c,java_objectheader *loader)
        c->classloader = definingloader;
 
        /* insert class into the loaded class cache */
-       if (!classcache_store(loader,c))
-               return false;
-
-       return true;
+       /* XXX free classinfo if NULL returned? */
+       return classcache_store(loader,c,true);
 }
 
 
@@ -2709,9 +2890,11 @@ fieldinfo *class_findfield(classinfo *c, utf *name, utf *desc)
                        return &(c->fields[i]);                                                         
     }
 
-       panic("Can not find field given in CONSTANT_Fieldref");
+       log_text("Can not find field given in CONSTANT_Fieldref");
+       assert(0);
 
        /* keep compiler happy */
+
        return NULL;
 }
 
@@ -2801,7 +2984,7 @@ fieldinfo *class_resolvefield(classinfo *c, utf *name, utf *desc,
 methodinfo *class_findmethod(classinfo *c, utf *name, utf *desc)
 {
        methodinfo *m;
-       s4 i;
+       s4          i;
 
        for (i = 0; i < c->methodscount; i++) {
                m = &(c->methods[i]);
@@ -2830,7 +3013,9 @@ methodinfo *class_fetchmethod(classinfo *c, utf *name, utf *desc)
                log_plain("Class: "); if (c) log_plain_utf(c->name); log_nl();
                log_plain("Method: "); if (name) log_plain_utf(name); log_nl();
                log_plain("Descriptor: "); if (desc) log_plain_utf(desc); log_nl();
-               panic("Method not found");
+
+               log_text("Method not found");
+               assert(0);
        }
 
        return mi;
@@ -2861,8 +3046,8 @@ methodinfo *class_findmethod_approx(classinfo *c, utf *name, utf *desc)
                                char *desc_utf_ptr = desc->text;      
                                char *meth_utf_ptr = meth_descr->text;                                    
                                /* points behind utf strings */
-                               char *desc_end = utf_end(desc);         
-                               char *meth_end = utf_end(meth_descr);   
+                               char *desc_end = UTF_END(desc);         
+                               char *meth_end = UTF_END(meth_descr);   
                                char ch;
 
                                /* compare argument types */
@@ -2872,7 +3057,7 @@ methodinfo *class_findmethod_approx(classinfo *c, utf *name, utf *desc)
                                                break; /* no match */
 
                                        if (ch == ')')
-                                               return &(c->methods[i]);   /* all parameter types equal */
+                                               return &(c->methods[i]); /* all parameter types equal */
                                }
                        }
                }
@@ -2937,7 +3122,7 @@ static methodinfo *class_resolveinterfacemethod_intern(classinfo *c,
                                                                                                           utf *name, utf *desc)
 {
        methodinfo *m;
-       s4 i;
+       s4          i;
        
        m = class_findmethod(c, name, desc);
 
@@ -2947,7 +3132,8 @@ static methodinfo *class_resolveinterfacemethod_intern(classinfo *c,
        /* try the superinterfaces */
 
        for (i = 0; i < c->interfacescount; i++) {
-               m = class_resolveinterfacemethod_intern(c->interfaces[i].cls, name, desc);
+               m = class_resolveinterfacemethod_intern(c->interfaces[i].cls,
+                                                                                               name, desc);
 
                if (m)
                        return m;
@@ -2988,7 +3174,7 @@ methodinfo *class_resolveinterfacemethod(classinfo *c, utf *name, utf *desc,
                return mi;
 
        /* try class java.lang.Object */
-       LOADER_ASSERT(class_java_lang_Object);
+
        mi = class_findmethod(class_java_lang_Object, name, desc);
 
        if (mi)
@@ -3004,11 +3190,11 @@ methodinfo *class_resolveinterfacemethod(classinfo *c, utf *name, utf *desc,
 
 /* class_resolveclassmethod ****************************************************
        
-    Resolves a reference from REFERER to a method with NAME and DESC in
-    class C.
+   Resolves a reference from REFERER to a method with NAME and DESC in
+   class C.
 
-    If the method cannot be resolved the return value is NULL. If EXCEPT is
-    true *exceptionptr is set, too.
+   If the method cannot be resolved the return value is NULL. If
+   EXCEPT is true *exceptionptr is set, too.
 
 *******************************************************************************/
 
@@ -3047,7 +3233,8 @@ methodinfo *class_resolveclassmethod(classinfo *c, utf *name, utf *desc,
        /* try the superinterfaces */
 
        for (i = 0; i < c->interfacescount; i++) {
-               mi = class_resolveinterfacemethod_intern(c->interfaces[i].cls, name, desc);
+               mi = class_resolveinterfacemethod_intern(c->interfaces[i].cls,
+                                                                                                name, desc);
 
                if (mi)
                        goto found;
@@ -3171,7 +3358,8 @@ void class_showconstanti(classinfo *c, int ii)
                        utf_display(e);
                        break;
                default: 
-                       panic("Invalid type of ConstantPool-Entry");
+                       log_text("Invalid type of ConstantPool-Entry");
+                       assert(0);
                }
        }
        printf("\n");
@@ -3252,7 +3440,8 @@ void class_showconstantpool (classinfo *c)
                                utf_display (e);
                                break;
                        default: 
-                               panic ("Invalid type of ConstantPool-Entry");
+                               log_text("Invalid type of ConstantPool-Entry");
+                               assert(0);
                        }
                }