A "direct superclass of an interface" is defined as any of the interfaces
listed in an interface's implemented interfaces, and _not_ in the "super"
field of the class struct (which must always be java/lang/Object).

In other words, when looking up interface methods, we shouldn't search
->super at all, but search ->interfaces[] instead.

Reported-by: Tomek Grabiec <tgrab...@gmail.com>
Signed-off-by: Vegard Nossum <vegard.nos...@gmail.com>
---
 vm/class.c |   19 ++++++++++++++++++-
 1 files changed, 18 insertions(+), 1 deletions(-)

diff --git a/vm/class.c b/vm/class.c
index 5382377..07fbdf5 100644
--- a/vm/class.c
+++ b/vm/class.c
@@ -682,6 +682,23 @@ struct vm_method *vm_class_get_method_recursive(const 
struct vm_class *vmc,
        return NULL;
 }
 
+static struct vm_method *vm_class_get_interface_method_recursive(
+       const struct vm_class *vmc, const char *name, const char *type)
+{
+       struct vm_method *vmm = vm_class_get_method(vmc, name, type);
+       if (vmm)
+               return vmm;
+
+       for (unsigned int i = 0; i < vmc->nr_interfaces; ++i) {
+               vmm = vm_class_get_interface_method_recursive(
+                       vmc->interfaces[i], name, type);
+               if (vmm)
+                       return vmm;
+       }
+
+       return NULL;
+}
+
 int vm_class_resolve_interface_method(const struct vm_class *vmc, uint16_t i,
        struct vm_class **r_vmc, char **r_name, char **r_type)
 {
@@ -776,7 +793,7 @@ vm_class_resolve_interface_method_recursive(const struct 
vm_class *vmc,
                return NULL;
        }
 
-       result = vm_class_get_method_recursive(class, name, type);
+       result = vm_class_get_interface_method_recursive(class, name, type);
 
        free(name);
        free(type);
-- 
1.6.0.4


------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time, 
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
Jatovm-devel mailing list
Jatovm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jatovm-devel

Reply via email to