PatchSet 6611 
Date: 2005/06/09 10:52:23
Author: hkraemer
Branch: HEAD
Tag: (none) 
Log:
fixed creation of miranda methods

Members: 
        ChangeLog:1.4137->1.4138 
        kaffe/kaffevm/classMethod.c:1.145->1.146 

Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.4137 kaffe/ChangeLog:1.4138
--- kaffe/ChangeLog:1.4137      Sun Jun  5 02:43:31 2005
+++ kaffe/ChangeLog     Thu Jun  9 10:52:23 2005
@@ -1,3 +1,11 @@
+2005-06-09  Helmer Kraemer  <[EMAIL PROTECTED]>
+
+       * kaffe/kaffevm/classMethod.c (expandMethods): create new 
parsed_signature_t for
+       created method
+       (duplicateParsedSignature): new method
+
+       Fixes bug reported by Daniel Bonniot <[EMAIL PROTECTED]>
+
 2005-06-05  Ito Kazumitsu  <[EMAIL PROTECTED]>
 
        * libraries/javalib/gnu/java/nio/charset/iconv/IconvProvider.java
Index: kaffe/kaffe/kaffevm/classMethod.c
diff -u kaffe/kaffe/kaffevm/classMethod.c:1.145 
kaffe/kaffe/kaffevm/classMethod.c:1.146
--- kaffe/kaffe/kaffevm/classMethod.c:1.145     Mon May 30 21:16:02 2005
+++ kaffe/kaffe/kaffevm/classMethod.c   Thu Jun  9 10:52:25 2005
@@ -75,6 +75,7 @@
 static bool resolveStaticFields(Hjava_lang_Class*, errorInfo *einfo);
 static bool resolveConstants(Hjava_lang_Class*, errorInfo *einfo);
 static bool resolveInterfaces(Hjava_lang_Class *class, errorInfo *einfo);
+static parsed_signature_t *duplicateParsedSignature (parsed_signature_t *, 
errorInfo *);
 
 static struct Hjava_security_ProtectionDomain  *defaultProtectionDomain;
 
@@ -703,15 +704,28 @@
                int i;
                
                i = CLASS_NMETHODS(cl);
-               CLASS_NMETHODS(cl) = i + 1;
                CLASS_METHODS(cl) = new_methods;
                utf8ConstAddRef(imeth->name);
-               utf8ConstAddRef(imeth->parsed_sig->signature);
                new_methods[i] = *imeth;
+
+               /* Allocate a new parsed_signature_t for the method. We can't 
use the one
+                * of the implemented method as destroyClass would then try to 
free it
+                * twice.
+                */
+               new_methods[i].parsed_sig = duplicateParsedSignature 
(imeth->parsed_sig, einfo);
+               if (new_methods[i].parsed_sig == NULL)
+               {
+                       gc_free (new_methods);
+                       return 0;
+               }
+
                new_methods[i].ndeclared_exceptions = -1;
                new_methods[i].declared_exceptions_u.remote_exceptions =
                        imeth;
                new_methods[i].class = cl;
+
+               CLASS_NMETHODS(cl) = i + 1;
+
                retval = 1;
        }
        else
@@ -2010,7 +2024,7 @@
                        /* skip inaccessible methods */
                        if (!checkAccess (meth->class, super, mt->accflags))
                                continue;
- 
+
                        if (utf8ConstEqual (mt->name, meth->name) &&
                            utf8ConstEqual (METHOD_SIG(mt), METHOD_SIG(meth)))
                        {
@@ -2784,6 +2798,31 @@
        }
 
        return (nargs);
+}
+
+/*
+ * Duplicates a parsed signature.
+ */
+static parsed_signature_t*
+duplicateParsedSignature(parsed_signature_t *orig, errorInfo *einfo)
+{
+       parsed_signature_t *ret;
+       size_t sizeOfSignature;
+
+       sizeOfSignature = sizeof(*ret) + orig->nargs * 
sizeof(ret->ret_and_args[0]);
+
+       ret = (parsed_signature_t *)gc_malloc (sizeOfSignature, 
KGC_ALLOC_CLASSMISC);
+
+       if (ret == NULL) {
+               postOutOfMemory(einfo);
+               return NULL;
+       }
+
+       memcpy (ret, orig, sizeOfSignature);
+
+       utf8ConstAddRef (PSIG_UTF8(ret));
+
+       return ret;
 }
 
 /*

_______________________________________________
kaffe mailing list
[email protected]
http://kaffe.org/cgi-bin/mailman/listinfo/kaffe

Reply via email to