Signed-off-by: Tomek Grabiec <tgrab...@gmail.com> --- include/vm/reflection.h | 1 + vm/jato.c | 1 + vm/reflection.c | 28 ++++++++++++++++++++++++++++ 3 files changed, 30 insertions(+), 0 deletions(-)
diff --git a/include/vm/reflection.h b/include/vm/reflection.h index f695651..27e987b 100644 --- a/include/vm/reflection.h +++ b/include/vm/reflection.h @@ -19,5 +19,6 @@ native_constructor_construct_native(struct vm_object *this, struct vm_object *args, struct vm_object *declaring_class, int slot); +struct vm_object *native_vmclass_get_interfaces(struct vm_object *clazz); #endif /* __JATO_VM_REFLECTION_H */ diff --git a/vm/jato.c b/vm/jato.c index 96f56e3..0d2bd73 100644 --- a/vm/jato.c +++ b/vm/jato.c @@ -663,6 +663,7 @@ static struct vm_native natives[] = { DEFINE_NATIVE("java/lang/VMClass", "isPrimitive", &native_vmclass_isprimitive), DEFINE_NATIVE("java/lang/VMClass", "getModifiers", &native_vmclass_getmodifiers), DEFINE_NATIVE("java/lang/VMClass", "getComponentType", &native_vmclass_getcomponenttype), + DEFINE_NATIVE("java/lang/VMClass", "getInterfaces", &native_vmclass_get_interfaces), DEFINE_NATIVE("java/lang/VMClassLoader", "getPrimitiveClass", &native_vmclassloader_getprimitiveclass), DEFINE_NATIVE("java/io/VMFile", "isDirectory", &native_vmfile_is_directory), DEFINE_NATIVE("java/lang/VMObject", "clone", &native_vmobject_clone), diff --git a/vm/reflection.c b/vm/reflection.c index 65998ac..9ce8d46 100644 --- a/vm/reflection.c +++ b/vm/reflection.c @@ -198,3 +198,31 @@ native_constructor_construct_native(struct vm_object *this, vm_call_method_object(vmm, result); return result; } + +struct vm_object *native_vmclass_get_interfaces(struct vm_object *clazz) +{ + struct vm_class *vmc; + + if (!vm_object_is_instance_of(clazz, vm_java_lang_Class)) + return NULL; + + vmc = vm_class_get_class_from_class_object(clazz); + + struct vm_object *array + = vm_object_alloc_array(vm_array_of_java_lang_Class, + vmc->nr_interfaces); + if (!array) { + NOT_IMPLEMENTED; + return NULL; + } + + for (unsigned int i = 0; i < vmc->nr_interfaces; i++) { + vm_class_ensure_init(vmc->interfaces[i]); + if (exception_occurred()) + return NULL; + + array_set_field_ptr(array, i, vmc->interfaces[i]->object); + } + + return array; +} -- 1.6.0.6 ------------------------------------------------------------------------------ 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