* Removed all Id tags.
[cacao.git] / src / vmcore / method.c
index 87715ad96a343e2b898a231744a73d3041d11b6a..17e40bd785443145b26172755bdd0cd3b1290fc0 100644 (file)
@@ -22,8 +22,6 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: method.c 8295 2007-08-11 17:57:24Z michi $
-
 */
 
 
@@ -37,6 +35,8 @@
 
 #include "mm/memory.h"
 
+#include "native/llni.h"
+
 #include "threads/lock-common.h"
 
 #include "vm/builtin.h"
@@ -624,14 +624,14 @@ int32_t method_get_parametercount(methodinfo *m)
 
 *******************************************************************************/
 
-java_objectarray *method_get_parametertypearray(methodinfo *m)
+java_handle_objectarray_t *method_get_parametertypearray(methodinfo *m)
 {
-       methoddesc       *md;
-       typedesc         *paramtypes;
-       int32_t           paramcount;
-       java_objectarray *oa;
-       int32_t           i;
-       classinfo        *c;
+       methoddesc                *md;
+       typedesc                  *paramtypes;
+       int32_t                    paramcount;
+       java_handle_objectarray_t *oa;
+       int32_t                    i;
+       classinfo                 *c;
 
        md = m->parseddesc;
 
@@ -664,7 +664,7 @@ java_objectarray *method_get_parametertypearray(methodinfo *m)
                if (!resolve_class_from_typedesc(&paramtypes[i], true, false, &c))
                        return NULL;
 
-               oa->data[i] = c;
+               LLNI_array_direct(oa, i) = (java_object_t *) c;
        }
 
        return oa;
@@ -677,11 +677,11 @@ java_objectarray *method_get_parametertypearray(methodinfo *m)
 
 *******************************************************************************/
 
-java_objectarray *method_get_exceptionarray(methodinfo *m)
+java_handle_objectarray_t *method_get_exceptionarray(methodinfo *m)
 {
-       java_objectarray *oa;
-       classinfo        *c;
-       s4                i;
+       java_handle_objectarray_t *oa;
+       classinfo                 *c;
+       s4                         i;
 
        /* create class-array */
 
@@ -698,7 +698,7 @@ java_objectarray *method_get_exceptionarray(methodinfo *m)
                if (c == NULL)
                        return NULL;
 
-               oa->data[i] = c;
+               LLNI_array_direct(oa, i) = (java_object_t *) c;
        }
 
        return oa;
@@ -774,23 +774,40 @@ s4 method_count_implementations(methodinfo *m, classinfo *c, methodinfo **found)
 }
 
 
-#if defined(ENABLE_ANNOTATIONS)
 /* method_get_annotations ******************************************************
 
    Gets a methods' annotations (or NULL if none).
 
 *******************************************************************************/
 
-annotation_bytearray_t *method_get_annotations(methodinfo *m)
+java_handle_bytearray_t *method_get_annotations(methodinfo *m)
 {
-       classinfo *c = m->class;
-       int slot = m - c->methods;
-
+#if defined(ENABLE_ANNOTATIONS)
+       classinfo               *c;
+       int                      slot;
+       annotation_bytearray_t  *ba;
+       java_handle_bytearray_t *annotations;
+
+       c           = m->class;
+       slot        = m - c->methods;
+       annotations = NULL;
+       
        if (c->method_annotations != NULL && c->method_annotations->size > slot) {
-               return c->method_annotations->data[slot];
+               ba = c->method_annotations->data[slot];
+               
+               if (ba != NULL) {
+                       annotations = builtin_newarray_byte(ba->size);
+                       
+                       if (annotations != NULL) {
+                               MCOPY(annotations->data, ba->data, uint8_t, ba->size);
+                       }
+               }
        }
-
+       
+       return annotations;
+#else
        return NULL;
+#endif
 }
 
 
@@ -800,17 +817,35 @@ annotation_bytearray_t *method_get_annotations(methodinfo *m)
 
 *******************************************************************************/
 
-annotation_bytearray_t *method_get_parameterannotations(methodinfo *m)
+java_handle_bytearray_t *method_get_parameterannotations(methodinfo *m)
 {
-       classinfo *c = m->class;
-       int slot = m - c->methods;
+#if defined(ENABLE_ANNOTATIONS)
+       classinfo               *c;
+       int                      slot;
+       annotation_bytearray_t  *ba;
+       java_handle_bytearray_t *parameterAnnotations;
+
+       c                    = m->class;
+       slot                 = m - c->methods;
+       parameterAnnotations = NULL;
 
        if (c->method_parameterannotations != NULL &&
                c->method_parameterannotations->size > slot) {
-               return c->method_parameterannotations->data[slot];
+               ba = c->method_parameterannotations->data[slot];
+               
+               if (ba != NULL) {
+                       parameterAnnotations = builtin_newarray_byte(ba->size);
+                       
+                       if (parameterAnnotations != NULL) {
+                               MCOPY(parameterAnnotations->data, ba->data, uint8_t, ba->size);
+                       }
+               }
        }
-
+       
+       return parameterAnnotations;
+#else
        return NULL;
+#endif
 }
 
 
@@ -820,19 +855,36 @@ annotation_bytearray_t *method_get_parameterannotations(methodinfo *m)
 
 *******************************************************************************/
 
-annotation_bytearray_t *method_get_annotationdefault(methodinfo *m)
+java_handle_bytearray_t *method_get_annotationdefault(methodinfo *m)
 {
-       classinfo *c = m->class;
-       int slot = m - c->methods;
+#if defined(ENABLE_ANNOTATIONS)
+       classinfo               *c;
+       int                      slot;
+       annotation_bytearray_t  *ba;
+       java_handle_bytearray_t *annotationDefault;
+
+       c                 = m->class;
+       slot              = m - c->methods;
+       annotationDefault = NULL;
 
        if (c->method_annotationdefaults != NULL &&
                c->method_annotationdefaults->size > slot) {
-               return c->method_annotationdefaults->data[slot];
+               ba = c->method_annotationdefaults->data[slot];
+               
+               if (ba != NULL) {
+                       annotationDefault = builtin_newarray_byte(ba->size);
+                       
+                       if (annotationDefault != NULL) {
+                               MCOPY(annotationDefault->data, ba->data, uint8_t, ba->size);
+                       }
+               }
        }
-
+       
+       return annotationDefault;
+#else
        return NULL;
-}
 #endif
+}
 
 
 /* method_add_to_worklist ******************************************************