Signed-off-by: Vegard Nossum <vegard.nos...@gmail.com> --- vm/class.c | 23 +++++++++++++++++++++++ 1 files changed, 23 insertions(+), 0 deletions(-)
diff --git a/vm/class.c b/vm/class.c index abd3a5b..aced89b 100644 --- a/vm/class.c +++ b/vm/class.c @@ -204,6 +204,22 @@ static int insert_interface_method(struct vm_class *vmc, return array_append(extra_methods, vmm); } +static int compare_method_signatures(const void *a, const void *b) +{ + const struct vm_method *x = *(const struct vm_method **) a; + const struct vm_method *y = *(const struct vm_method **) b; + + int name = strcmp(x->name, y->name); + if (name) + return name; + + int type = strcmp(x->type, y->type); + if (type) + return type; + + return 0; +} + int vm_class_link(struct vm_class *vmc, const struct cafebabe_class *class) { vmc->class = class; @@ -416,6 +432,13 @@ int vm_class_link(struct vm_class *vmc, const struct cafebabe_class *class) } } + /* We need to weed out duplicate signatures in order to avoid a + * situation where two interfaces define the same method and a class + * implements both interfaces. We shouldn't add two methods with the + * same signature to the same class. */ + array_qsort(&extra_methods, &compare_method_signatures); + array_unique(&extra_methods, &compare_method_signatures); + vmc->nr_methods = class->methods_count + extra_methods.size; vmc->methods = malloc(sizeof(*vmc->methods) * vmc->nr_methods); -- 1.6.0.4 ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Jatovm-devel mailing list Jatovm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jatovm-devel