* load_newly_created_array: Save native stub to m->entrypoint, so that the
[cacao.git] / src / vm / resolve.c
index cf1cc203c1671130c7c2986beee3763054180d21..25fd37683e6e2cfba712bb55f9e1e1cd3d12a6b4 100644 (file)
@@ -26,9 +26,9 @@
 
    Authors: Edwin Steiner
 
-   Changes:
+   Changes: Christan Thalinger
 
-   $Id: resolve.c 2217 2005-04-05 10:26:33Z edwin $
+   $Id: resolve.c 3031 2005-07-13 11:52:50Z twisti $
 
 */
 
 #include "vm/resolve.h"
 #include "vm/access.h"
 #include "vm/classcache.h"
+#include "vm/descriptor.h"
 #include "vm/exceptions.h"
-#include "vm/loader.h"
 #include "vm/linker.h"
-#include "vm/classcache.h"
-#include "vm/descriptor.h"
+#include "vm/loader.h"
+#include "vm/stringlocal.h"
 #include "vm/jit/jit.h"
 #include "vm/jit/verify/typeinfo.h"
 
@@ -73,6 +73,8 @@ bool
 resolve_class_from_name(classinfo *referer,methodinfo *refmethod,
                          utf *classname,
                          resolve_mode_t mode,
+                         bool checkaccess,
+                         bool link,
                          classinfo **result)
 {
        classinfo *cls = NULL;
@@ -91,11 +93,12 @@ resolve_class_from_name(classinfo *referer,methodinfo *refmethod,
        utf_fprint(stderr,referer->name);
        fprintf(stderr,",");
        utf_fprint(stderr,classname);
-       fprintf(stderr,")\n");
+       fprintf(stderr,",%d,%d)\n",(int)checkaccess,(int)link);
 #endif
 
        /* lookup if this class has already been loaded */
-       cls = classcache_lookup(referer->classloader,classname);
+
+       cls = classcache_lookup(referer->classloader, classname);
 
 #ifdef RESOLVE_VERBOSE
        fprintf(stderr,"    lookup result: %p\n",(void*)cls);
@@ -103,10 +106,13 @@ resolve_class_from_name(classinfo *referer,methodinfo *refmethod,
        
        if (!cls) {
                /* resolve array types */
+
                if (classname->text[0] == '[') {
                        utf_ptr = classname->text + 1;
                        len = classname->blength - 1;
+
                        /* classname is an array type name */
+
                        switch (*utf_ptr) {
                                case 'L':
                                        utf_ptr++;
@@ -117,7 +123,7 @@ resolve_class_from_name(classinfo *referer,methodinfo *refmethod,
                                        /* resolve the component type */
                                        if (!resolve_class_from_name(referer,refmethod,
                                                                           utf_new(utf_ptr,len),
-                                                                          mode,&cls))
+                                                                          mode,checkaccess,link,&cls))
                                                return false; /* exception */
                                        if (!cls) {
                                                RESOLVE_ASSERT(mode == resolveLazy);
@@ -141,7 +147,8 @@ resolve_class_from_name(classinfo *referer,methodinfo *refmethod,
 
                /* load the class */
                if (!cls) {
-                       if (!load_class_from_classloader(classname,referer->classloader,&cls))
+                       if (!(cls = load_class_from_classloader(classname,
+                                                                                                       referer->classloader)))
                                return false; /* exception */
                }
        }
@@ -155,12 +162,30 @@ resolve_class_from_name(classinfo *referer,methodinfo *refmethod,
 #endif
        
        /* check access rights of referer to refered class */
-       if (!is_accessible_class(referer,cls)) {
-               *exceptionptr = new_exception_message(string_java_lang_IllegalAccessException,
-                               "class is not accessible XXX add message");
+       if (checkaccess && !is_accessible_class(referer,cls)) {
+               int msglen;
+               char *message;
+
+               msglen = utf_strlen(cls->name) + utf_strlen(referer->name) + 100;
+               message = MNEW(char,msglen);
+               strcpy(message,"class is not accessible (");
+               utf_sprint_classname(message+strlen(message),cls->name);
+               strcat(message," from ");
+               utf_sprint_classname(message+strlen(message),referer->name);
+               strcat(message,")");
+               *exceptionptr = new_exception_message(string_java_lang_IllegalAccessException,message);
+               MFREE(message,char,msglen);
                return false; /* exception */
        }
 
+       /* link the class if necessary */
+       if (link) {
+               if (!cls->linked)
+                       if (!link_class(cls))
+                               return false; /* exception */
+               RESOLVE_ASSERT(cls->linked);
+       }
+
        /* resolution succeeds */
 #ifdef RESOLVE_VERBOSE
        fprintf(stderr,"    success.\n");
@@ -173,20 +198,24 @@ bool
 resolve_classref(methodinfo *refmethod,
                                 constant_classref *ref,
                                 resolve_mode_t mode,
+                                bool checkaccess,
                             bool link,
                                 classinfo **result)
 {
-       return resolve_classref_or_classinfo(refmethod,CLASSREF_OR_CLASSINFO(ref),mode,link,result);
+       return resolve_classref_or_classinfo(refmethod,CLASSREF_OR_CLASSINFO(ref),mode,checkaccess,link,result);
 }
 
 bool
 resolve_classref_or_classinfo(methodinfo *refmethod,
                                                          classref_or_classinfo cls,
                                                          resolve_mode_t mode,
+                                                         bool checkaccess,
                                                          bool link,
                                                          classinfo **result)
 {
-       classinfo *c;
+       classinfo         *c;
+       java_objectheader *e;
+       java_objectheader *cause;
        
        RESOLVE_ASSERT(cls.any);
        RESOLVE_ASSERT(mode == resolveEager || mode == resolveLazy);
@@ -195,18 +224,19 @@ resolve_classref_or_classinfo(methodinfo *refmethod,
 #ifdef RESOLVE_VERBOSE
        fprintf(stderr,"resolve_classref_or_classinfo(");
        utf_fprint(stderr,(IS_CLASSREF(cls)) ? cls.ref->name : cls.cls->name);
-       fprintf(stderr,",%i,%i)\n",mode,link);
+       fprintf(stderr,",%i,%i,%i)\n",mode,(int)checkaccess,(int)link);
 #endif
 
        *result = NULL;
 
        if (IS_CLASSREF(cls)) {
                /* we must resolve this reference */
-               if (!resolve_class_from_name(cls.ref->referer,refmethod,cls.ref->name,
-                                                                       mode,&c))
-                       return false; /* exception */
-       }
-       else {
+
+               if (!resolve_class_from_name(cls.ref->referer, refmethod, cls.ref->name,
+                                                                        mode, checkaccess, link, &c))
+                       goto return_exception;
+
+       } else {
                /* cls has already been resolved */
                c = cls.cls;
                RESOLVE_ASSERT(c->loaded);
@@ -222,17 +252,49 @@ resolve_classref_or_classinfo(methodinfo *refmethod,
        if (link) {
                if (!c->linked)
                        if (!link_class(c))
-                               return false; /* exception */
+                               goto return_exception;
+
                RESOLVE_ASSERT(c->linked);
        }
 
        /* succeeded */
        *result = c;
        return true;
+
+ return_exception:
+       /* get the cause */
+
+       cause = *exceptionptr;
+
+       /* convert ClassNotFoundException's to NoClassDefFoundError's */
+
+       if (builtin_instanceof(cause, class_java_lang_ClassNotFoundException)) {
+               /* clear exception, because we are calling jit code again */
+
+               *exceptionptr = NULL;
+
+               /* create new error */
+
+               e = new_exception_javastring(string_java_lang_NoClassDefFoundError,
+                                                                        ((java_lang_Throwable *) cause)->detailMessage);
+
+               /* we had an exception while creating the error */
+
+               if (*exceptionptr)
+                       return false;
+
+               /* set new exception */
+
+               *exceptionptr = e;
+       }
+
+       *result = NULL;
+       return false;
 }
 
+
 bool 
-resolve_class_from_typedesc(typedesc *d,bool link,classinfo **result)
+resolve_class_from_typedesc(typedesc *d, bool checkaccess, bool link, classinfo **result)
 {
        classinfo *cls;
        
@@ -244,13 +306,13 @@ resolve_class_from_typedesc(typedesc *d,bool link,classinfo **result)
 #ifdef RESOLVE_VERBOSE
        fprintf(stderr,"resolve_class_from_typedesc(");
        descriptor_debug_print_typedesc(stderr,d);
-       fprintf(stderr,",%i)\n",link);
+       fprintf(stderr,",%i,%i)\n",(int)checkaccess,(int)link);
 #endif
 
        if (d->classref) {
                /* a reference type */
                if (!resolve_classref_or_classinfo(NULL,CLASSREF_OR_CLASSINFO(d->classref),
-                                                                                  resolveEager,link,&cls))
+                                                                                  resolveEager,checkaccess,link,&cls))
                        return false; /* exception */
        }
        else {
@@ -292,6 +354,9 @@ resolve_and_check_subtype_set(classinfo *referer,methodinfo *refmethod,
        classinfo *type;
        typeinfo resultti;
        typeinfo typeti;
+       char *message;
+       int msglen;
+       typecheck_result r;
 
        RESOLVE_ASSERT(referer);
        RESOLVE_ASSERT(ref);
@@ -324,7 +389,7 @@ resolve_and_check_subtype_set(classinfo *referer,methodinfo *refmethod,
                *checked = false;
 
        /* first resolve the type if necessary */
-       if (!resolve_classref_or_classinfo(refmethod,typeref,mode,true,&type))
+       if (!resolve_classref_or_classinfo(refmethod,typeref,mode,false,true,&type))
                return false; /* exception */
        if (!type)
                return true; /* be lazy */
@@ -336,7 +401,7 @@ resolve_and_check_subtype_set(classinfo *referer,methodinfo *refmethod,
 
        for (; setp->any; ++setp) {
                /* first resolve the set member if necessary */
-               if (!resolve_classref_or_classinfo(refmethod,*setp,mode,true,&result))
+               if (!resolve_classref_or_classinfo(refmethod,*setp,mode,false,true,&result))
                        return false; /* exception */
                if (!result)
                        return true; /* be lazy */
@@ -356,7 +421,10 @@ resolve_and_check_subtype_set(classinfo *referer,methodinfo *refmethod,
                TYPEINFO_INIT_CLASSINFO(resultti,result);
                if (reversed) {
                        /* we must test against `true` because `MAYBE` is also != 0 */
-                       if (true != typeinfo_is_assignable_to_class(&typeti,CLASSREF_OR_CLASSINFO(result))) {
+                       r = typeinfo_is_assignable_to_class(&typeti,CLASSREF_OR_CLASSINFO(result));
+                       if (r == typecheck_FAIL)
+                               return false;
+                       if (r != typecheck_TRUE) {
 #ifdef RESOLVE_VERBOSE
                                fprintf(stderr,"reversed subclass test failed\n");
 #endif
@@ -365,7 +433,10 @@ resolve_and_check_subtype_set(classinfo *referer,methodinfo *refmethod,
                }
                else {
                        /* we must test against `true` because `MAYBE` is also != 0 */
-                       if (true != typeinfo_is_assignable_to_class(&resultti,CLASSREF_OR_CLASSINFO(type))) {
+                       r = typeinfo_is_assignable_to_class(&resultti,CLASSREF_OR_CLASSINFO(type));
+                       if (r == typecheck_FAIL)
+                               return false;
+                       if (r != typecheck_TRUE) {
 #ifdef RESOLVE_VERBOSE
                                fprintf(stderr,"subclass test failed\n");
 #endif
@@ -380,12 +451,20 @@ resolve_and_check_subtype_set(classinfo *referer,methodinfo *refmethod,
        return true;
 
 throw_error:
+       msglen = utf_strlen(result->name) + utf_strlen(type->name) + 200;
+       message = MNEW(char,msglen);
+       strcpy(message,(error == resolveIllegalAccessError) ?
+                       "illegal access to protected member ("
+                       : "subtype constraint violated (");
+       utf_sprint_classname(message+strlen(message),result->name);
+       strcat(message," is not a subclass of ");
+       utf_sprint_classname(message+strlen(message),type->name);
+       strcat(message,")");
        if (error == resolveIllegalAccessError)
-               *exceptionptr = new_exception_message(string_java_lang_IllegalAccessException,
-                               "illegal access to protected member XXX add message");
+               *exceptionptr = new_exception_message(string_java_lang_IllegalAccessException,message);
        else
-               *exceptionptr = new_exception_message(string_java_lang_LinkageError,
-                               "subtype constraint violated XXX add message");
+               *exceptionptr = new_exception_message(string_java_lang_LinkageError,message);
+       MFREE(message,char,msglen);
        return false; /* exception */
 }
 
@@ -397,6 +476,7 @@ throw_error:
 bool
 resolve_class(unresolved_class *ref,
                          resolve_mode_t mode,
+                         bool checkaccess,
                          classinfo **result)
 {
        classinfo *cls;
@@ -414,7 +494,7 @@ resolve_class(unresolved_class *ref,
 
        /* first we must resolve the class */
        if (!resolve_classref(ref->referermethod,
-                                             ref->classref,mode,true,&cls))
+                                             ref->classref,mode,checkaccess,true,&cls))
        {
                /* the class reference could not be resolved */
                return false; /* exception */
@@ -471,12 +551,13 @@ resolve_field(unresolved_field *ref,
 #endif
 
        /* the class containing the reference */
+
        referer = ref->fieldref->classref->referer;
        RESOLVE_ASSERT(referer);
 
        /* first we must resolve the class containg the field */
        if (!resolve_class_from_name(referer,ref->referermethod,
-                                          ref->fieldref->classref->name,mode,&container))
+                                          ref->fieldref->classref->name,mode,true,true,&container))
        {
                /* the class reference could not be resolved */
                return false; /* exception */
@@ -510,6 +591,7 @@ resolve_field(unresolved_field *ref,
 #endif
 
        /* check static */
+
        if (((fi->flags & ACC_STATIC) != 0) != ((ref->flags & RESOLVE_STATIC) != 0)) {
                /* a static field is accessed via an instance, or vice versa */
                *exceptionptr = new_exception_message(string_java_lang_IncompatibleClassChangeError,
@@ -518,8 +600,10 @@ resolve_field(unresolved_field *ref,
                return false; /* exception */
        }
 
-       /* for non-static accesses we have to check the constraints on the instance type */
-       if ((ref->flags & RESOLVE_STATIC) == 0) {
+       /* for non-static accesses we have to check the constraints on the */
+       /* instance type */
+
+       if (!(ref->flags & RESOLVE_STATIC)) {
 #ifdef RESOLVE_VERBOSE
                fprintf(stderr,"    checking instance types...\n");
 #endif
@@ -527,29 +611,35 @@ resolve_field(unresolved_field *ref,
                if (!resolve_and_check_subtype_set(referer,ref->referermethod,
                                                                                   &(ref->instancetypes),
                                                                                   CLASSREF_OR_CLASSINFO(container),
-                                                                                  false,
-                                                                                  mode,
-                                                                                  resolveLinkageError,&checked))
+                                                                                  false, mode, resolveLinkageError,
+                                                                                  &checked))
                {
                        return false; /* exception */
                }
+
                if (!checked)
                        return true; /* be lazy */
        }
 
+#ifdef RESOLVE_VERBOSE
+       fprintf(stderr,"    checking instance types...done\n");
+#endif
+
        fieldtyperef = ref->fieldref->parseddesc.fd->classref;
 
        /* for PUT* instructions we have to check the constraints on the value type */
        if (((ref->flags & RESOLVE_PUTFIELD) != 0) && fi->type == TYPE_ADR) {
+#ifdef RESOLVE_VERBOSE
+               fprintf(stderr,"    checking value constraints...\n");
+#endif
                RESOLVE_ASSERT(fieldtyperef);
                if (!SUBTYPESET_IS_EMPTY(ref->valueconstraints)) {
                        /* check subtype constraints */
-                       if (!resolve_and_check_subtype_set(referer,ref->referermethod,
+                       if (!resolve_and_check_subtype_set(referer, ref->referermethod,
                                                                                           &(ref->valueconstraints),
                                                                                           CLASSREF_OR_CLASSINFO(fieldtyperef),
-                                                                                          false,
-                                                                                          mode,
-                                                                                          resolveLinkageError,&checked))
+                                                                                          false, mode, resolveLinkageError,
+                                                                                          &checked))
                        {
                                return false; /* exception */
                        }
@@ -559,37 +649,71 @@ resolve_field(unresolved_field *ref,
        }
                                                                           
        /* check access rights */
+#ifdef RESOLVE_VERBOSE
+       fprintf(stderr,"    checking access rights...\n");
+#endif
        if (!is_accessible_member(referer,declarer,fi->flags)) {
-               *exceptionptr = new_exception_message(string_java_lang_IllegalAccessException,
-                               "field is not accessible XXX add message");
+               int msglen;
+               char *message;
+
+               msglen = utf_strlen(declarer->name) + utf_strlen(fi->name) + utf_strlen(referer->name) + 100;
+               message = MNEW(char,msglen);
+               strcpy(message,"field is not accessible (");
+               utf_sprint_classname(message+strlen(message),declarer->name);
+               strcat(message,".");
+               utf_sprint(message+strlen(message),fi->name);
+               strcat(message," from ");
+               utf_sprint_classname(message+strlen(message),referer->name);
+               strcat(message,")");
+               *exceptionptr = new_exception_message(string_java_lang_IllegalAccessException,message);
+               MFREE(message,char,msglen);
                return false; /* exception */
        }
+#ifdef RESOLVE_VERBOSE
+       fprintf(stderr,"    checking access rights...done\n");
+       fprintf(stderr,"        declarer = ");
+       utf_fprint_classname(stderr,declarer->name); fputc('\n',stderr);
+       fprintf(stderr,"        referer = ");
+       utf_fprint_classname(stderr,referer->name); fputc('\n',stderr);
+#endif
 
        /* check protected access */
        if (((fi->flags & ACC_PROTECTED) != 0) && !SAME_PACKAGE(declarer,referer)) {
+#ifdef RESOLVE_VERBOSE
+               fprintf(stderr,"    checking protectec access...\n");
+#endif
                if (!resolve_and_check_subtype_set(referer,ref->referermethod,
                                                                                   &(ref->instancetypes),
                                                                                   CLASSREF_OR_CLASSINFO(referer),
-                                                                                  false,
-                                                                                  mode,
-                                                                                  resolveIllegalAccessError,&checked))
+                                                                                  false, mode,
+                                                                                  resolveIllegalAccessError, &checked))
                {
                        return false; /* exception */
                }
+
                if (!checked)
                        return true; /* be lazy */
        }
 
        /* impose loading constraint on field type */
+
        if (fi->type == TYPE_ADR) {
+#ifdef RESOLVE_VERBOSE
+               fprintf(stderr,"    adding constraint...\n");
+#endif
                RESOLVE_ASSERT(fieldtyperef);
-               if (!classcache_add_constraint(declarer->classloader,referer->classloader,
-                                                                          fieldtyperef->name))
-                       return false; /* exception */
+               if (!classcache_add_constraint(declarer->classloader,
+                                                                          referer->classloader,
+                                                                          fieldtyperef->name))
+                       return false;
        }
 
        /* succeed */
+#ifdef RESOLVE_VERBOSE
+       fprintf(stderr,"    success.\n");
+#endif
        *result = fi;
+
        return true;
 }
 
@@ -599,9 +723,7 @@ resolve_field(unresolved_field *ref,
 
 /* for documentation see resolve.h */
 bool
-resolve_method(unresolved_method *ref,
-                          resolve_mode_t mode,
-                          methodinfo **result)
+resolve_method(unresolved_method *ref, resolve_mode_t mode, methodinfo **result)
 {
        classinfo *referer;
        classinfo *container;
@@ -628,7 +750,7 @@ resolve_method(unresolved_method *ref,
 
        /* first we must resolve the class containg the method */
        if (!resolve_class_from_name(referer,ref->referermethod,
-                                          ref->methodref->classref->name,mode,&container))
+                                          ref->methodref->classref->name,mode,true,true,&container))
        {
                /* the class reference could not be resolved */
                return false; /* exception */
@@ -641,34 +763,51 @@ resolve_method(unresolved_method *ref,
        /* now we must find the declaration of the method in `container`
         * or one of its superclasses */
 
-       if ((container->flags & ACC_INTERFACE) != 0) {
+       if (container->flags & ACC_INTERFACE) {
                mi = class_resolveinterfacemethod(container,
-                                                                             ref->methodref->name,ref->methodref->descriptor,
-                                                                             referer,true);
-       }
-       else {
+                                                                             ref->methodref->name,
+                                                                                 ref->methodref->descriptor,
+                                                                             referer, true);
+
+       } else {
                mi = class_resolveclassmethod(container,
-                                                                         ref->methodref->name,ref->methodref->descriptor,
-                                                                         referer,true);
+                                                                         ref->methodref->name,
+                                                                         ref->methodref->descriptor,
+                                                                         referer, true);
        }
+
        if (!mi)
                return false; /* exception */ /* XXX set exceptionptr? */
 
+#ifdef RESOLVE_VERBOSE
+       fprintf(stderr,"    flags: %02x\n",mi->flags);
+#endif
        /* { the method reference has been resolved } */
+
        declarer = mi->class;
        RESOLVE_ASSERT(declarer);
 
        /* check static */
+
        if (((mi->flags & ACC_STATIC) != 0) != ((ref->flags & RESOLVE_STATIC) != 0)) {
                /* a static method is accessed via an instance, or vice versa */
-               *exceptionptr = new_exception_message(string_java_lang_IncompatibleClassChangeError,
+               *exceptionptr =
+                       new_exception_message(string_java_lang_IncompatibleClassChangeError,
                                (mi->flags & ACC_STATIC) ? "static method called via instance"
                                                         : "instance method called without instance");
-               return false; /* exception */
+               return false;
        }
 
-       /* for non-static methods we have to check the constraints on the instance type */
-       if ((ref->flags & RESOLVE_STATIC) == 0) {
+       /* have the method params already been parsed? no, do it. */
+
+       if (!mi->parseddesc->params)
+               if (!descriptor_params_from_paramtypes(mi->parseddesc, mi->flags))
+                       return false;
+               
+       /* for non-static methods we have to check the constraints on the         */
+       /* instance type                                                          */
+
+       if (!(ref->flags & RESOLVE_STATIC)) {
                if (!resolve_and_check_subtype_set(referer,ref->referermethod,
                                                                                   &(ref->instancetypes),
                                                                                   CLASSREF_OR_CLASSINFO(container),
@@ -687,16 +826,16 @@ resolve_method(unresolved_method *ref,
        }
 
        /* check subtype constraints for TYPE_ADR parameters */
-       RESOLVE_ASSERT((mi->paramcount-instancecount) == ref->methodref->parseddesc.md->paramcount);
-       paramtypes = ref->methodref->parseddesc.md->paramtypes;
+
+       RESOLVE_ASSERT(mi->parseddesc->paramcount == ref->methodref->parseddesc.md->paramcount);
+       paramtypes = mi->parseddesc->paramtypes;
        
-       for (i=0; i<(mi->paramcount-instancecount); ++i) {
-               if (mi->paramtypes[instancecount + i] == TYPE_ADR) {
-                       RESOLVE_ASSERT(paramtypes[i].type == TYPE_ADR);
+       for (i = 0; i < mi->parseddesc->paramcount-instancecount; i++) {
+               if (paramtypes[i+instancecount].type == TYPE_ADR) {
                        if (ref->paramconstraints) {
                                if (!resolve_and_check_subtype_set(referer,ref->referermethod,
                                                        ref->paramconstraints + i,
-                                                       CLASSREF_OR_CLASSINFO(paramtypes[i].classref),
+                                                       CLASSREF_OR_CLASSINFO(paramtypes[i+instancecount].classref),
                                                        false,
                                                        mode,
                                                        resolveLinkageError,&checked))
@@ -710,14 +849,32 @@ resolve_method(unresolved_method *ref,
        }
 
        /* check access rights */
+
        if (!is_accessible_member(referer,declarer,mi->flags)) {
-               *exceptionptr = new_exception_message(string_java_lang_IllegalAccessException,
-                               "method is not accessible XXX add message");
+               int msglen;
+               char *message;
+
+               msglen = utf_strlen(declarer->name) + utf_strlen(mi->name) + 
+                       utf_strlen(mi->descriptor) + utf_strlen(referer->name) + 100;
+               message = MNEW(char,msglen);
+               strcpy(message,"method is not accessible (");
+               utf_sprint_classname(message+strlen(message),declarer->name);
+               strcat(message,".");
+               utf_sprint(message+strlen(message),mi->name);
+               utf_sprint(message+strlen(message),mi->descriptor);
+               strcat(message," from ");
+               utf_sprint_classname(message+strlen(message),referer->name);
+               strcat(message,")");
+               *exceptionptr = new_exception_message(string_java_lang_IllegalAccessException,message);
+               MFREE(message,char,msglen);
                return false; /* exception */
        }
 
        /* check protected access */
-       if (((mi->flags & ACC_PROTECTED) != 0) && !SAME_PACKAGE(declarer,referer)) {
+
+       if (((mi->flags & ACC_PROTECTED) != 0) && !SAME_PACKAGE(declarer,referer)
+                       && (declarer->name->text[0] == '['))
+       {
                if (!resolve_and_check_subtype_set(referer,ref->referermethod,
                                                                                   &(ref->instancetypes),
                                                                                   CLASSREF_OR_CLASSINFO(referer),
@@ -732,9 +889,11 @@ resolve_method(unresolved_method *ref,
        }
 
        /* impose loading constraints on parameters (including instance) */
-       paramtypes = ref->methodref->parseddesc.md->paramtypes - instancecount;
-       for (i=0; i<mi->paramcount; ++i) {
-               if (mi->paramtypes[i] == TYPE_ADR) {
+
+       paramtypes = mi->parseddesc->paramtypes;
+
+       for (i = 0; i < mi->parseddesc->paramcount; i++) {
+               if (i < instancecount || paramtypes[i].type == TYPE_ADR) {
                        utf *name;
                        
                        if (i < instancecount)
@@ -742,12 +901,14 @@ resolve_method(unresolved_method *ref,
                        else
                                name = paramtypes[i].classref->name;
                        
-                       if (!classcache_add_constraint(referer->classloader,declarer->classloader,name))
+                       if (!classcache_add_constraint(referer->classloader,
+                                                                                  declarer->classloader, name))
                                return false; /* exception */
                }
        }
 
        /* impose loading constraing onto return type */
+
        if (ref->methodref->parseddesc.md->returntype.type == TYPE_ADR) {
                if (!classcache_add_constraint(referer->classloader,declarer->classloader,
                                ref->methodref->parseddesc.md->returntype.classref->name))
@@ -777,8 +938,7 @@ unresolved_subtype_set_from_typeinfo(classinfo *referer,methodinfo *refmethod,
 #ifdef RESOLVE_VERBOSE
        fprintf(stderr,"unresolved_subtype_set_from_typeinfo\n");
 #ifdef TYPEINFO_DEBUG
-       /*typeinfo_print(stderr,tinfo,4);*/
-       fprintf(stderr,"\n");
+       typeinfo_print(stderr,tinfo,4);
 #endif
        fprintf(stderr,"    declared type:");utf_fprint(stderr,declaredtype->name);
        fprintf(stderr,"\n");
@@ -811,7 +971,19 @@ unresolved_subtype_set_from_typeinfo(classinfo *referer,methodinfo *refmethod,
                count = tinfo->merged->count;
                stset->subtyperefs = MNEW(classref_or_classinfo,count + 1);
                for (i=0; i<count; ++i) {
-                       stset->subtyperefs[i] = tinfo->merged->list[i];
+                       classref_or_classinfo c = tinfo->merged->list[i];
+                       if (tinfo->dimension > 0) {
+                               /* a merge of array types */
+                               /* the merged list contains the possible _element_ types, */
+                               /* so we have to create array types with these elements.  */
+                               if (IS_CLASSREF(c)) {
+                                       c.ref = class_get_classref_multiarray_of(tinfo->dimension,c.ref);
+                               }
+                               else {
+                                       c.cls = class_multiarray_of(tinfo->dimension,c.cls,false);
+                               }
+                       }
+                       stset->subtyperefs[i] = c;
                }
                stset->subtyperefs[count].any = NULL; /* terminate */
        }
@@ -820,6 +992,8 @@ unresolved_subtype_set_from_typeinfo(classinfo *referer,methodinfo *refmethod,
                                        ? tinfo->typeclass.ref->name 
                                        : tinfo->typeclass.cls->name) == declaredtype->name)
                {
+                       /* the class names are the same */
+                   /* equality is guaranteed by the loading constraints */
                        goto empty_set;
                }
                else {
@@ -836,6 +1010,22 @@ empty_set:
        return true;
 }
 
+/* create_unresolved_class *****************************************************
+   Create an unresolved_class struct for the given class reference
+  
+   IN:
+          refmethod........the method triggering the resolution (if any)
+          classref.........the class reference
+          valuetype........value type to check against the resolved class
+                                               may be NULL, if no typeinfo is available
+
+   RETURN VALUE:
+       a pointer to a new unresolved_class struct, or
+          NULL if an exception has been thrown
+
+*******************************************************************************/
+
 unresolved_class *
 create_unresolved_class(methodinfo *refmethod,
                                                constant_classref *classref,
@@ -843,13 +1033,13 @@ create_unresolved_class(methodinfo *refmethod,
 {
        unresolved_class *ref;
        
-       RESOLVE_ASSERT(ref);
-       
 #ifdef RESOLVE_VERBOSE
        fprintf(stderr,"create_unresolved_class\n");
        fprintf(stderr,"    referer: ");utf_fprint(stderr,classref->referer->name);fputc('\n',stderr);
-       fprintf(stderr,"    rmethod: ");utf_fprint(stderr,refmethod->name);fputc('\n',stderr);
-       fprintf(stderr,"    rmdesc : ");utf_fprint(stderr,refmethod->descriptor);fputc('\n',stderr);
+       if (refmethod) {
+               fprintf(stderr,"    rmethod: ");utf_fprint(stderr,refmethod->name);fputc('\n',stderr);
+               fprintf(stderr,"    rmdesc : ");utf_fprint(stderr,refmethod->descriptor);fputc('\n',stderr);
+       }
        fprintf(stderr,"    name   : ");utf_fprint(stderr,classref->name);fputc('\n',stderr);
 #endif
 
@@ -869,18 +1059,27 @@ create_unresolved_class(methodinfo *refmethod,
        return ref;
 }
 
+/* create_unresolved_field *****************************************************
+   Create an unresolved_field struct for the given field access instruction
+  
+   IN:
+       referer..........the class containing the reference
+          refmethod........the method triggering the resolution (if any)
+          iptr.............the {GET,PUT}{FIELD,STATIC}{,CONST} instruction
+
+   RETURN VALUE:
+       a pointer to a new unresolved_field struct, or
+          NULL if an exception has been thrown
+
+*******************************************************************************/
+
 unresolved_field *
-create_unresolved_field(classinfo *referer,methodinfo *refmethod,
-                                               instruction *iptr,
-                                               stackelement *stack)
+create_unresolved_field(classinfo *referer, methodinfo *refmethod,
+                                               instruction *iptr)
 {
        unresolved_field *ref;
        constant_FMIref *fieldref = NULL;
-       stackelement *instanceslot = NULL;
-       int type;
-       typeinfo tinfo;
-       typeinfo *tip = NULL;
-       typedesc *fd;
 
 #ifdef RESOLVE_VERBOSE
        fprintf(stderr,"create_unresolved_field\n");
@@ -892,36 +1091,30 @@ create_unresolved_field(classinfo *referer,methodinfo *refmethod,
        ref = NEW(unresolved_field);
        ref->flags = 0;
        ref->referermethod = refmethod;
+       UNRESOLVED_SUBTYPE_SET_EMTPY(ref->valueconstraints);
 
        switch (iptr[0].opc) {
                case ICMD_PUTFIELD:
                        ref->flags |= RESOLVE_PUTFIELD;
-                       if (stack) {
-                               instanceslot = stack->prev;
-                               tip = &(stack->typeinfo);
-                       }
                        fieldref = (constant_FMIref *) iptr[0].val.a;
                        break;
 
                case ICMD_PUTFIELDCONST:
                        ref->flags |= RESOLVE_PUTFIELD;
-                       if (stack) instanceslot = stack;
-                       fieldref = INSTRUCTION_PUTCONST_FIELDREF(iptr);
+                       fieldref = (constant_FMIref *) iptr[1].val.a;
                        break;
 
                case ICMD_PUTSTATIC:
                        ref->flags |= RESOLVE_PUTFIELD | RESOLVE_STATIC;
                        fieldref = (constant_FMIref *) iptr[0].val.a;
-                       if (stack) tip = &(stack->typeinfo);
                        break;
 
                case ICMD_PUTSTATICCONST:
                        ref->flags |= RESOLVE_PUTFIELD | RESOLVE_STATIC;
-                       fieldref = INSTRUCTION_PUTCONST_FIELDREF(iptr);
+                       fieldref = (constant_FMIref *) iptr[1].val.a;
                        break;
 
                case ICMD_GETFIELD:
-                       if (stack) instanceslot = stack;
                        fieldref = (constant_FMIref *) iptr[0].val.a;
                        break;
                        
@@ -932,9 +1125,6 @@ create_unresolved_field(classinfo *referer,methodinfo *refmethod,
        }
        
        RESOLVE_ASSERT(fieldref);
-       RESOLVE_ASSERT(!stack || instanceslot || ((ref->flags & RESOLVE_STATIC) != 0));
-       fd = fieldref->parseddesc.fd;
-       RESOLVE_ASSERT(fd);
 
 #ifdef RESOLVE_VERBOSE
        fprintf(stderr,"    class  : ");utf_fprint(stderr,fieldref->classref->name);fputc('\n',stderr);
@@ -946,18 +1136,111 @@ create_unresolved_field(classinfo *referer,methodinfo *refmethod,
 #endif
 
        ref->fieldref = fieldref;
+
+       return ref;
+}
+
+/* constrain_unresolved_field **************************************************
+   Record subtype constraints for a field access.
+  
+   IN:
+       ref..............the unresolved_field structure of the access
+       referer..........the class containing the reference
+          refmethod........the method triggering the resolution (if any)
+          iptr.............the {GET,PUT}{FIELD,STATIC}{,CONST} instruction
+          stack............the input stack of the instruction
+
+   RETURN VALUE:
+       true.............everything ok
+          false............an exception has been thrown
+
+*******************************************************************************/
+
+bool
+constrain_unresolved_field(unresolved_field *ref,
+                                                  classinfo *referer, methodinfo *refmethod,
+                                                  instruction *iptr,
+                                                  stackelement *stack)
+{
+       constant_FMIref *fieldref;
+       stackelement *instanceslot = NULL;
+       int type;
+       typeinfo tinfo;
+       typeinfo *tip = NULL;
+       typedesc *fd;
+
+       RESOLVE_ASSERT(ref);
+
+       fieldref = ref->fieldref;
+       RESOLVE_ASSERT(fieldref);
+
+#ifdef RESOLVE_VERBOSE
+       fprintf(stderr,"constrain_unresolved_field\n");
+       fprintf(stderr,"    referer: ");utf_fprint(stderr,referer->name);fputc('\n',stderr);
+       fprintf(stderr,"    rmethod: ");utf_fprint(stderr,refmethod->name);fputc('\n',stderr);
+       fprintf(stderr,"    rmdesc : ");utf_fprint(stderr,refmethod->descriptor);fputc('\n',stderr);
+       fprintf(stderr,"    class  : ");utf_fprint(stderr,fieldref->classref->name);fputc('\n',stderr);
+       fprintf(stderr,"    name   : ");utf_fprint(stderr,fieldref->name);fputc('\n',stderr);
+       fprintf(stderr,"    desc   : ");utf_fprint(stderr,fieldref->descriptor);fputc('\n',stderr);
+       fprintf(stderr,"    type   : ");descriptor_debug_print_typedesc(stderr,fieldref->parseddesc.fd);
+       fputc('\n',stderr);
+       /*fprintf(stderr,"    opcode : %d %s\n",iptr[0].opc,icmd_names[iptr[0].opc]);*/
+#endif
+
+       switch (iptr[0].opc) {
+               case ICMD_PUTFIELD:
+                       instanceslot = stack->prev;
+                       tip = &(stack->typeinfo);
+                       break;
+
+               case ICMD_PUTFIELDCONST:
+                       instanceslot = stack;
+                       break;
+
+               case ICMD_PUTSTATIC:
+                       tip = &(stack->typeinfo);
+                       break;
+
+               case ICMD_GETFIELD:
+                       instanceslot = stack;
+                       break;
+       }
        
+       RESOLVE_ASSERT(instanceslot || ((ref->flags & RESOLVE_STATIC) != 0));
+       fd = fieldref->parseddesc.fd;
+       RESOLVE_ASSERT(fd);
+
        /* record subtype constraints for the instance type, if any */
        if (instanceslot) {
                typeinfo *insttip;
-               RESOLVE_ASSERT(instanceslot->type == TYPE_ADR);
+
+               /* The instanceslot must contain a reference to a non-array type */
+               if (!TYPEINFO_IS_REFERENCE(instanceslot->typeinfo)) {
+                       *exceptionptr = new_verifyerror(refmethod, "illegal instruction: field access on non-reference");
+                       return false;
+               }
+               if (TYPEINFO_IS_ARRAY(instanceslot->typeinfo)) {
+                       *exceptionptr = new_verifyerror(refmethod, "illegal instruction: field access on array");
+                       return false;
+               }
                
                if (((ref->flags & RESOLVE_PUTFIELD) != 0) && 
                                TYPEINFO_IS_NEWOBJECT(instanceslot->typeinfo))
-               {   /* XXX clean up */
+               {
+                       /* The instruction writes a field in an uninitialized object. */
+                       /* This is only allowed when a field of an uninitialized 'this' object is */
+                       /* written inside an initialization method                                */
+                       
+                       classinfo *initclass;
                        instruction *ins = (instruction*)TYPEINFO_NEWOBJECT_INSTRUCTION(instanceslot->typeinfo);
-                       classinfo *initclass = (ins) ? (classinfo*)ins[-1].val.a 
-                                                                                : refmethod->class; /* XXX classrefs */
+
+                       if (ins != NULL) {
+                               *exceptionptr = new_verifyerror(refmethod,"accessing field of uninitialized object");
+                               return false;
+                       }
+                       /* XXX check that class of field == refmethod->class */
+                       initclass = refmethod->class; /* XXX classrefs */
                        RESOLVE_ASSERT(initclass->loaded && initclass->linked);
                        TYPEINFO_INIT_CLASSINFO(tinfo,initclass);
                        insttip = &tinfo;
@@ -967,7 +1250,7 @@ create_unresolved_field(classinfo *referer,methodinfo *refmethod,
                }
                if (!unresolved_subtype_set_from_typeinfo(referer,refmethod,
                                        &(ref->instancetypes),insttip,fieldref->classref))
-                       return NULL;
+                       return false;
        }
        else {
                UNRESOLVED_SUBTYPE_SET_EMTPY(ref->instancetypes);
@@ -975,7 +1258,7 @@ create_unresolved_field(classinfo *referer,methodinfo *refmethod,
        
        /* record subtype constraints for the value type, if any */
        type = fd->type;
-       if (stack && type == TYPE_ADR && ((ref->flags & RESOLVE_PUTFIELD) != 0)) {
+       if (type == TYPE_ADR && ((ref->flags & RESOLVE_PUTFIELD) != 0)) {
                if (!tip) {
                        /* we have a PUTSTATICCONST or PUTFIELDCONST with TYPE_ADR */
                        tip = &tinfo;
@@ -990,33 +1273,41 @@ create_unresolved_field(classinfo *referer,methodinfo *refmethod,
                }
                if (!unresolved_subtype_set_from_typeinfo(referer,refmethod,
                                        &(ref->valueconstraints),tip,fieldref->parseddesc.fd->classref))
-                       return NULL;
+                       return false;
        }
        else {
                UNRESOLVED_SUBTYPE_SET_EMTPY(ref->valueconstraints);
        }
 
-       return ref;
+       return true;
 }
 
+/* create_unresolved_method ****************************************************
+   Create an unresolved_method struct for the given method invocation
+  
+   IN:
+       referer..........the class containing the reference
+          refmethod........the method triggering the resolution (if any)
+          iptr.............the INVOKE* instruction
+
+   RETURN VALUE:
+       a pointer to a new unresolved_method struct, or
+          NULL if an exception has been thrown
+
+*******************************************************************************/
+
 unresolved_method *
-create_unresolved_method(classinfo *referer,methodinfo *refmethod,
-                                                instruction *iptr,
-                                                stackelement *stack)
+create_unresolved_method(classinfo *referer, methodinfo *refmethod,
+                                                instruction *iptr)
 {
        unresolved_method *ref;
        constant_FMIref *methodref;
-       stackelement *instanceslot = NULL;
-       stackelement *param;
-       methoddesc *md;
-       typeinfo tinfo;
-       int i,j;
-       int type;
+       bool staticmethod;
 
        methodref = (constant_FMIref *) iptr[0].val.a;
        RESOLVE_ASSERT(methodref);
-       md = methodref->parseddesc.md;
-       RESOLVE_ASSERT(md);
+       staticmethod = (iptr[0].opc == ICMD_INVOKESTATIC);
 
 #ifdef RESOLVE_VERBOSE
        fprintf(stderr,"create_unresolved_method\n");
@@ -1029,32 +1320,85 @@ create_unresolved_method(classinfo *referer,methodinfo *refmethod,
        /*fprintf(stderr,"    opcode : %d %s\n",iptr[0].opc,icmd_names[iptr[0].opc]);*/
 #endif
 
+       /* allocate params if necessary */
+       if (!methodref->parseddesc.md->params)
+               if (!descriptor_params_from_paramtypes(methodref->parseddesc.md,
+                                       (staticmethod) ? ACC_STATIC : ACC_NONE))
+                       return NULL;
+
+       /* create the data structure */
        ref = NEW(unresolved_method);
-       ref->flags = 0;
+       ref->flags = (staticmethod) ? RESOLVE_STATIC : 0;
        ref->referermethod = refmethod;
        ref->methodref = methodref;
        ref->paramconstraints = NULL;
+       UNRESOLVED_SUBTYPE_SET_EMTPY(ref->instancetypes);
 
-       switch (iptr[0].opc) {
-               case ICMD_INVOKESTATIC:
-                       ref->flags |= RESOLVE_STATIC;
-                       break;
-               case ICMD_INVOKEVIRTUAL:
-               case ICMD_INVOKESPECIAL:
-               case ICMD_INVOKEINTERFACE:
-                       break;
-               default:
-                       RESOLVE_ASSERT(false);
-       }
+       return ref;
+}
+
+/* constrain_unresolved_method *************************************************
+   Record subtype constraints for the arguments of a method call.
+  
+   IN:
+       ref..............the unresolved_method structure of the call
+       referer..........the class containing the reference
+          refmethod........the method triggering the resolution (if any)
+          iptr.............the INVOKE* instruction
+          stack............the input stack of the instruction
+
+   RETURN VALUE:
+       true.............everything ok
+          false............an exception has been thrown
+
+*******************************************************************************/
+
+bool
+constrain_unresolved_method(unresolved_method *ref,
+                                                       classinfo *referer, methodinfo *refmethod,
+                                                       instruction *iptr,
+                                                       stackelement *stack)
+{
+       constant_FMIref *methodref;
+       stackelement *instanceslot = NULL;
+       stackelement *param;
+       methoddesc *md;
+       typeinfo tinfo;
+       int i,j;
+       int type;
+       int instancecount;
+
+       RESOLVE_ASSERT(ref);
+       methodref = ref->methodref;
+       RESOLVE_ASSERT(methodref);
+       md = methodref->parseddesc.md;
+       RESOLVE_ASSERT(md);
+       RESOLVE_ASSERT(md->params != NULL);
 
-       if (stack && (ref->flags & RESOLVE_STATIC) == 0) {
+#ifdef RESOLVE_VERBOSE
+       fprintf(stderr,"constrain_unresolved_method\n");
+       fprintf(stderr,"    referer: ");utf_fprint(stderr,referer->name);fputc('\n',stderr);
+       fprintf(stderr,"    rmethod: ");utf_fprint(stderr,refmethod->name);fputc('\n',stderr);
+       fprintf(stderr,"    rmdesc : ");utf_fprint(stderr,refmethod->descriptor);fputc('\n',stderr);
+       fprintf(stderr,"    class  : ");utf_fprint(stderr,methodref->classref->name);fputc('\n',stderr);
+       fprintf(stderr,"    name   : ");utf_fprint(stderr,methodref->name);fputc('\n',stderr);
+       fprintf(stderr,"    desc   : ");utf_fprint(stderr,methodref->descriptor);fputc('\n',stderr);
+       /*fprintf(stderr,"    opcode : %d %s\n",iptr[0].opc,icmd_names[iptr[0].opc]);*/
+#endif
+
+       if ((ref->flags & RESOLVE_STATIC) == 0) {
                /* find the instance slot under all the parameter slots on the stack */
                instanceslot = stack;
-               for (i=0; i<md->paramcount; ++i)
+               for (i=1; i<md->paramcount; ++i)
                        instanceslot = instanceslot->prev;
+               instancecount = 1;
+       }
+       else {
+               instancecount = 0;
        }
        
-       RESOLVE_ASSERT(!stack || instanceslot || ((ref->flags & RESOLVE_STATIC) != 0));
+       RESOLVE_ASSERT((instanceslot && instancecount==1) || ((ref->flags & RESOLVE_STATIC) != 0));
 
        /* record subtype constraints for the instance type, if any */
        if (instanceslot) {
@@ -1066,52 +1410,47 @@ create_unresolved_method(classinfo *referer,methodinfo *refmethod,
                                TYPEINFO_IS_NEWOBJECT(instanceslot->typeinfo))
                {   /* XXX clean up */
                        instruction *ins = (instruction*)TYPEINFO_NEWOBJECT_INSTRUCTION(instanceslot->typeinfo);
-                       classinfo *initclass = (ins) ? (classinfo*)ins[-1].val.a 
-                                                                                : refmethod->class; /* XXX classrefs */
-                       RESOLVE_ASSERT(initclass->loaded && initclass->linked);
-                       TYPEINFO_INIT_CLASSINFO(tinfo,initclass);
+                       classref_or_classinfo initclass = (ins) ? CLASSREF_OR_CLASSINFO(ins[-1].val.a)
+                                                                                : CLASSREF_OR_CLASSINFO(refmethod->class);
                        tip = &tinfo;
+                       if (!typeinfo_init_class(tip,initclass))
+                               return false;
                }
                else {
                        tip = &(instanceslot->typeinfo);
                }
                if (!unresolved_subtype_set_from_typeinfo(referer,refmethod,
                                        &(ref->instancetypes),tip,methodref->classref))
-                       return NULL;
-       }
-       else {
-               UNRESOLVED_SUBTYPE_SET_EMTPY(ref->instancetypes);
+                       return false;
        }
        
        /* record subtype constraints for the parameter types, if any */
-       if (stack) {
-               param = stack;
-               for (i=md->paramcount-1; i>=0; --i, param=param->prev) {
-                       type = md->paramtypes[i].type;
-                       
-                       RESOLVE_ASSERT(param);
-                       RESOLVE_ASSERT(type == param->type);
-                       
-                       if (type == TYPE_ADR) {
-                               if (!ref->paramconstraints) {
-                                       ref->paramconstraints = MNEW(unresolved_subtype_set,md->paramcount);
-                                       for (j=md->paramcount-1; j>i; --j)
-                                               UNRESOLVED_SUBTYPE_SET_EMTPY(ref->paramconstraints[j]);
-                               }
-                               RESOLVE_ASSERT(ref->paramconstraints);
-                               if (!unresolved_subtype_set_from_typeinfo(referer,refmethod,
-                                                       ref->paramconstraints + i,&(param->typeinfo),
-                                                       md->paramtypes[i].classref))
-                                       return NULL;
-                       }
-                       else {
-                               if (ref->paramconstraints)
-                                       UNRESOLVED_SUBTYPE_SET_EMTPY(ref->paramconstraints[i]);
+       param = stack;
+       for (i=md->paramcount-1-instancecount; i>=0; --i, param=param->prev) {
+               type = md->paramtypes[i+instancecount].type;
+
+               RESOLVE_ASSERT(param);
+               RESOLVE_ASSERT(type == param->type);
+
+               if (type == TYPE_ADR) {
+                       if (!ref->paramconstraints) {
+                               ref->paramconstraints = MNEW(unresolved_subtype_set,md->paramcount);
+                               for (j=md->paramcount-1-instancecount; j>i; --j)
+                                       UNRESOLVED_SUBTYPE_SET_EMTPY(ref->paramconstraints[j]);
                        }
+                       RESOLVE_ASSERT(ref->paramconstraints);
+                       if (!unresolved_subtype_set_from_typeinfo(referer,refmethod,
+                                               ref->paramconstraints + i,&(param->typeinfo),
+                                               md->paramtypes[i+instancecount].classref))
+                               return false;
+               }
+               else {
+                       if (ref->paramconstraints)
+                               UNRESOLVED_SUBTYPE_SET_EMTPY(ref->paramconstraints[i]);
                }
        }
 
-       return ref;
+       return true;
 }
 
 /******************************************************************************/
@@ -1249,9 +1588,9 @@ unresolved_class_debug_dump(unresolved_class *ref,FILE *file)
        if (ref) {
                fprintf(file,"    referer   : ");
                utf_fprint(file,ref->classref->referer->name); fputc('\n',file);
-               fprintf(file,"    refmethod  : ");
+               fprintf(file,"    refmethod : ");
                utf_fprint(file,ref->referermethod->name); fputc('\n',file);
-               fprintf(file,"    refmethodd : ");
+               fprintf(file,"    refmethodd: ");
                utf_fprint(file,ref->referermethod->descriptor); fputc('\n',file);
                fprintf(file,"    classname : ");
                utf_fprint(file,ref->classref->name); fputc('\n',file);
@@ -1277,9 +1616,9 @@ unresolved_field_debug_dump(unresolved_field *ref,FILE *file)
        if (ref) {
                fprintf(file,"    referer   : ");
                utf_fprint(file,ref->fieldref->classref->referer->name); fputc('\n',file);
-               fprintf(file,"    refmethod  : ");
+               fprintf(file,"    refmethod : ");
                utf_fprint(file,ref->referermethod->name); fputc('\n',file);
-               fprintf(file,"    refmethodd : ");
+               fprintf(file,"    refmethodd: ");
                utf_fprint(file,ref->referermethod->descriptor); fputc('\n',file);
                fprintf(file,"    classname : ");
                utf_fprint(file,ref->fieldref->classref->name); fputc('\n',file);
@@ -1316,9 +1655,9 @@ unresolved_method_debug_dump(unresolved_method *ref,FILE *file)
        if (ref) {
                fprintf(file,"    referer   : ");
                utf_fprint(file,ref->methodref->classref->referer->name); fputc('\n',file);
-               fprintf(file,"    refmethod  : ");
+               fprintf(file,"    refmethod : ");
                utf_fprint(file,ref->referermethod->name); fputc('\n',file);
-               fprintf(file,"    refmethodd : ");
+               fprintf(file,"    refmethodd: ");
                utf_fprint(file,ref->referermethod->descriptor); fputc('\n',file);
                fprintf(file,"    classname : ");
                utf_fprint(file,ref->methodref->classref->name); fputc('\n',file);