2009/6/26 Tomek Grabiec <tgrab...@gmail.com>: > It's needed to get the class of array elements. > > Signed-off-by: Tomek Grabiec <tgrab...@gmail.com> > --- > include/vm/object.h | 1 + > vm/object.c | 9 +++++++++ > 2 files changed, 10 insertions(+), 0 deletions(-) > > diff --git a/include/vm/object.h b/include/vm/object.h > index 587b6bb..29eeb24 100644 > --- a/include/vm/object.h > +++ b/include/vm/object.h > @@ -26,6 +26,7 @@ struct vm_object *vm_object_alloc_native_array(int type, > int count); > struct vm_object *vm_object_alloc_multi_array(struct vm_class *class, > int nr_dimensions, int *count); > struct vm_object *vm_object_alloc_array(struct vm_class *class, int count); > +struct vm_class *vm_object_get_array_element_class(struct vm_object *array); > > struct vm_object * > vm_object_alloc_string(const uint8_t bytes[], unsigned int length); > diff --git a/vm/object.c b/vm/object.c > index 8dfc504..e5951a3 100644 > --- a/vm/object.c > +++ b/vm/object.c > @@ -139,6 +139,15 @@ struct vm_object *vm_object_alloc_array(struct vm_class > *class, int count) > return res; > } > > +struct vm_class *vm_object_get_array_element_class(struct vm_object *array) > +{ > + /* > + * Skip the '[' prefix of array class name to get elements' > + * class name. > + */ > + return classloader_load(array->class->name + 1); > +} > + > void vm_object_lock(struct vm_object *obj) > { > if (pthread_mutex_lock(&obj->mutex)) > --
Well, as I said on IRC, I think you'd have to remove the L...; as well. For array-of-ints, the class name is "[I", but for array-of-Objects, the class name would be "[Ljava/lang/Object;". I would also have liked to see some asserts in there. For example, you could: assert(vm_class_is_array_class(array->class)); BTW, you can find the description of that syntax here: http://java.sun.com/docs/books/jvms/second_edition/html/ClassFile.doc.html#1169 Hope I didn't screw up this time :-) Vegard ------------------------------------------------------------------------------ _______________________________________________ Jatovm-devel mailing list Jatovm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jatovm-devel