Signed-off-by: Tomek Grabiec <[email protected]>
---
include/vm/reflection.h | 1 +
vm/jato.c | 1 +
vm/reflection.c | 23 +++++++++++++++++++++++
3 files changed, 25 insertions(+), 0 deletions(-)
diff --git a/include/vm/reflection.h b/include/vm/reflection.h
index 27e987b..97ba29b 100644
--- a/include/vm/reflection.h
+++ b/include/vm/reflection.h
@@ -20,5 +20,6 @@ native_constructor_construct_native(struct vm_object *this,
struct vm_object *declaring_class,
int slot);
struct vm_object *native_vmclass_get_interfaces(struct vm_object *clazz);
+struct vm_object *native_vmclass_get_superclass(struct vm_object *clazz);
#endif /* __JATO_VM_REFLECTION_H */
diff --git a/vm/jato.c b/vm/jato.c
index 0d2bd73..d15a816 100644
--- a/vm/jato.c
+++ b/vm/jato.c
@@ -664,6 +664,7 @@ static struct vm_native natives[] = {
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/VMClass", "getSuperclass",
&native_vmclass_get_superclass),
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 9ce8d46..b319dc6 100644
--- a/vm/reflection.c
+++ b/vm/reflection.c
@@ -226,3 +226,26 @@ struct vm_object *native_vmclass_get_interfaces(struct
vm_object *clazz)
return array;
}
+
+struct vm_object *native_vmclass_get_superclass(struct vm_object *clazz)
+{
+ struct vm_class *vmc;
+
+ if (!clazz)
+ return NULL;
+
+ if (!vm_object_is_instance_of(clazz, vm_java_lang_Class))
+ return NULL;
+
+ vmc = vm_class_get_class_from_class_object(clazz);
+
+ if (vm_class_is_array_class(vmc))
+ return vm_java_lang_Object->object;
+
+ if (vm_class_is_interface(vmc) ||
+ vm_class_is_primitive_class(vmc) ||
+ vmc == vm_java_lang_Object)
+ return NULL;
+
+ return vmc->super->object;
+}
--
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/jatovm-devel