* src/native/vm/reflect.c
[cacao.git] / src / vmcore / method.c
index 87715ad96a343e2b898a231744a73d3041d11b6a..da7473d1d849bd5e646fd6116ebf7734ced7702f 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: method.c 8295 2007-08-11 17:57:24Z michi $
+   $Id: method.c 8315 2007-08-15 22:49:20Z panzi $
 
 */
 
@@ -781,16 +781,26 @@ s4 method_count_implementations(methodinfo *m, classinfo *c, methodinfo **found)
 
 *******************************************************************************/
 
-annotation_bytearray_t *method_get_annotations(methodinfo *m)
+java_bytearray *method_get_annotations(methodinfo *m)
 {
-       classinfo *c = m->class;
-       int slot = m - c->methods;
-
+       classinfo              *c           = m->class;
+       int                     slot        = m - c->methods;
+       annotation_bytearray_t *ba          = NULL;
+       java_bytearray         *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 NULL;
+       
+       return annotations;
 }
 
 
@@ -800,17 +810,27 @@ annotation_bytearray_t *method_get_annotations(methodinfo *m)
 
 *******************************************************************************/
 
-annotation_bytearray_t *method_get_parameterannotations(methodinfo *m)
+java_bytearray *method_get_parameterannotations(methodinfo *m)
 {
-       classinfo *c = m->class;
-       int slot = m - c->methods;
+       classinfo              *c                    = m->class;
+       int                     slot                 = m - c->methods;
+       annotation_bytearray_t *ba                   = NULL;
+       java_bytearray         *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 NULL;
+       
+       return parameterAnnotations;
 }
 
 
@@ -820,17 +840,27 @@ annotation_bytearray_t *method_get_parameterannotations(methodinfo *m)
 
 *******************************************************************************/
 
-annotation_bytearray_t *method_get_annotationdefault(methodinfo *m)
+java_bytearray *method_get_annotationdefault(methodinfo *m)
 {
-       classinfo *c = m->class;
-       int slot = m - c->methods;
+       classinfo              *c                 = m->class;
+       int                     slot              = m - c->methods;
+       annotation_bytearray_t *ba                = NULL;
+       java_bytearray         *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 NULL;
+       
+       return annotationDefault;
 }
 #endif