* src/native/vm/reflect.c
authorpanzi <none@none>
Wed, 15 Aug 2007 22:49:20 +0000 (22:49 +0000)
committerpanzi <none@none>
Wed, 15 Aug 2007 22:49:20 +0000 (22:49 +0000)
(reflect_constructor_new): Allocation of the java_bytearray is now done in the
method_get_* functions.
(reflect_field_new): Allocation of the java_bytearray is now done in the
field_get_* functions.
(reflect_method_new): Allocation of the java_bytearray is now done in the
method_get_* functions. Added use of LLNI_field_* macros.

* src/vmcore/method.c
(method_get_annotations): Do allocation of the java_bytearray here.
(method_get_parameterannotations): Do allocation of the java_bytearray here.
(method_get_annotationdefault): Do allocation of the java_bytearray here.

* src/vmcore/method.h
(method_get_annotations): This function now returns java_bytearray*.
(method_get_parameterannotations): This function now returns java_bytearray*.
(method_get_annotationdefault): This function now returns java_bytearray*.

* src/vmcore/field.c
(vm/builtin.h): Added include.
(field_get_annotations): Do allocation of the java_bytearray here.

* src/vmcore/field.h
(field_get_annotations): This function now returns java_bytearray*.

* src/cacaoh/dummy.c
(builtin_newarray_byte): Added.

src/cacaoh/dummy.c
src/native/vm/reflect.c
src/vmcore/field.c
src/vmcore/field.h
src/vmcore/method.c
src/vmcore/method.h

index 2f8206949ba6158ea514e0ae30fe54933491e832..061d1e699b88af377d0e4ff0db19ec22a6d0f8e4 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: dummy.c 8295 2007-08-11 17:57:24Z michi $
+   $Id: dummy.c 8315 2007-08-15 22:49:20Z panzi $
 
 */
 
@@ -130,6 +130,13 @@ java_objectarray *builtin_anewarray(int32_t size, classinfo *componentclass)
        return NULL;
 }
 
+java_bytearray *builtin_newarray_byte(int32_t size)
+{
+       abort();
+
+       return NULL;
+}
+
 
 /* code ***********************************************************************/
 
index 9281c70d1303b28ced37226e7bc3e5d72af70e31..fa761268fcd906af1ebf2dfed81b6349106f1976 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: reflect.c 8305 2007-08-15 13:49:26Z panzi $
+   $Id: reflect.c 8315 2007-08-15 22:49:20Z panzi $
 
 */
 
@@ -85,33 +85,6 @@ java_lang_reflect_Constructor *reflect_constructor_new(methodinfo *m)
        int32_t                        slot;
        java_bytearray                *annotations          = NULL;
        java_bytearray                *parameterAnnotations = NULL;
-       annotation_bytearray_t        *ba                   = NULL;
-
-#if defined(ENABLE_ANNOTATIONS)
-       /* get annotations */
-       ba = method_get_annotations(m);
-
-       if (ba != NULL) {
-               annotations = builtin_newarray_byte(ba->size);
-
-               if (annotations == NULL)
-                       return NULL;
-               
-               MCOPY(annotations->data, ba->data, uint8_t, ba->size);
-       }
-       
-       /* get parameter annotations */
-       ba = method_get_parameterannotations(m);
-
-       if (ba != NULL) {
-               parameterAnnotations = builtin_newarray_byte(ba->size);
-
-               if (parameterAnnotations == NULL)
-                       return NULL;
-               
-               MCOPY(parameterAnnotations->data, ba->data, uint8_t, ba->size);
-       }
-#endif
 
        /* get declaring class */
 
@@ -132,6 +105,16 @@ java_lang_reflect_Constructor *reflect_constructor_new(methodinfo *m)
 
        slot = m - c->methods;
 
+#if defined(ENABLE_ANNOTATIONS)
+       /* get annotations */
+
+       annotations = method_get_annotations(m);
+
+       /* get parameter annotations */
+
+       parameterAnnotations = method_get_parameterannotations(m);
+#endif
+
 #if defined(WITH_CLASSPATH_GNU)
 
        LLNI_field_set_cls(rc, clazz               , c);
@@ -172,21 +155,6 @@ java_lang_reflect_Field *reflect_field_new(fieldinfo *f)
        java_lang_reflect_Field *rf;
        int32_t                  slot;
        java_bytearray          *annotations = NULL;
-       annotation_bytearray_t  *ba          = NULL;
-
-#if defined(ENABLE_ANNOTATIONS)
-       /* get annotations */
-       ba = field_get_annotations(f);
-
-       if (ba != NULL) {
-               annotations = builtin_newarray_byte(ba->size);
-
-               if (annotations == NULL)
-                       return NULL;
-               
-               MCOPY(annotations->data, ba->data, uint8_t, ba->size);
-       }
-#endif
 
        /* get declaring class */
 
@@ -207,6 +175,12 @@ java_lang_reflect_Field *reflect_field_new(fieldinfo *f)
 
        slot = f - c->fields;
 
+#if defined(ENABLE_ANNOTATIONS)
+       /* get annotations */
+
+       annotations = field_get_annotations(f);
+#endif
+
 #if defined(WITH_CLASSPATH_GNU)
 
        LLNI_field_set_cls(rf, clazz         , c);
@@ -256,45 +230,6 @@ java_lang_reflect_Method *reflect_method_new(methodinfo *m)
        java_bytearray           *annotations          = NULL;
        java_bytearray           *parameterAnnotations = NULL;
        java_bytearray           *annotationDefault    = NULL;
-       annotation_bytearray_t   *ba                   = NULL;
-
-#if defined(ENABLE_ANNOTATIONS)
-       /* get annotations */
-       ba = method_get_annotations(m);
-
-       if (ba != NULL) {
-               annotations = builtin_newarray_byte(ba->size);
-
-               if (annotations == NULL)
-                       return NULL;
-               
-               MCOPY(annotations->data, ba->data, uint8_t, ba->size);
-       }
-       
-       /* get parameter annotations */
-       ba = method_get_parameterannotations(m);
-
-       if (ba != NULL) {
-               parameterAnnotations = builtin_newarray_byte(ba->size);
-
-               if (parameterAnnotations == NULL)
-                       return NULL;
-               
-               MCOPY(parameterAnnotations->data, ba->data, uint8_t, ba->size);
-       }
-
-       /* get annotation default value */
-       ba = method_get_annotationdefault(m);
-
-       if (ba != NULL) {
-               annotationDefault = builtin_newarray_byte(ba->size);
-
-               if (annotationDefault == NULL)
-                       return NULL;
-               
-               MCOPY(annotationDefault->data, ba->data, uint8_t, ba->size);
-       }
-#endif
 
        /* get declaring class */
 
@@ -315,6 +250,20 @@ java_lang_reflect_Method *reflect_method_new(methodinfo *m)
 
        slot = m - c->methods;
 
+#if defined(ENABLE_ANNOTATIONS)
+       /* get annotations */
+
+       annotations = method_get_annotations(m);
+
+       /* get parameter annotations */
+
+       parameterAnnotations = method_get_parameterannotations(m);
+
+       /* get annotation default value */
+
+       annotationDefault = method_get_annotationdefault(m);
+#endif
+
 #if defined(WITH_CLASSPATH_GNU)
 
        LLNI_field_set_cls(rm, clazz               , m->class);
@@ -330,21 +279,21 @@ java_lang_reflect_Method *reflect_method_new(methodinfo *m)
 
 #elif defined(WITH_CLASSPATH_SUN)
 
-       LLNI_field_set_cls(rm, clazz               , (java_lang_Class *) m->class);
+       LLNI_field_set_cls(rm, clazz               , m->class);
 
        /* The name needs to be interned */
        /* XXX implement me better! */
 
-       rm->name                 = _Jv_java_lang_String_intern((java_lang_String *) javastring_new(m->name));
-       rm->parameterTypes       = method_get_parametertypearray(m);
-       rm->returnType           = (java_lang_Class *) method_returntype_get(m);
-       rm->exceptionTypes       = method_get_exceptionarray(m);
-       rm->modifiers            = m->flags & ACC_CLASS_REFLECT_MASK;
-       rm->slot                 = slot;
-       rm->signature            = m->signature ? (java_lang_String *) javastring_new(m->signature) : NULL;
-       rm->annotations          = annotations;
-       rm->parameterAnnotations = parameterAnnotations;
-       rm->annotationDefault    = annotationDefault;
+       LLNI_field_set_ref(rm, name                , _Jv_java_lang_String_intern((java_lang_String *) javastring_new(m->name)));
+       LLNI_field_set_ref(rm, parameterTypes      , method_get_parametertypearray(m));
+       LLNI_field_set_cls(rm, returnType          , (java_lang_Class *) method_returntype_get(m));
+       LLNI_field_set_ref(rm, exceptionTypes      , method_get_exceptionarray(m));
+       LLNI_field_set_val(rm, modifiers           , m->flags & ACC_CLASS_REFLECT_MASK);
+       LLNI_field_set_val(rm, slot                , slot);
+       LLNI_field_set_ref(rm, signature           , m->signature ? (java_lang_String *) javastring_new(m->signature) : NULL);
+       LLNI_field_set_ref(rm, annotations         , annotations);
+       LLNI_field_set_ref(rm, parameterAnnotations, parameterAnnotations);
+       LLNI_field_set_ref(rm, annotationDefault   , annotationDefault);
 
 #else
 # error unknown classpath configuration
index 98e29f2a6a6ebaee94f69dfc26c0fe30ca05759d..5cd1a6e6cc90a95132cb41a87fdc37ee12b01f0d 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: field.c 8288 2007-08-10 15:12:00Z twisti $
+   $Id: field.c 8315 2007-08-15 22:49:20Z panzi $
 
 */
 
@@ -39,6 +39,7 @@
 
 #include "mm/memory.h"
 
+#include "vm/builtin.h"
 #include "vm/exceptions.h"
 #include "vm/global.h"
 #include "vm/primitive.h"
@@ -392,17 +393,26 @@ void field_free(fieldinfo *f)
 
 *******************************************************************************/
 
-annotation_bytearray_t *field_get_annotations(fieldinfo *f)
+java_bytearray *field_get_annotations(fieldinfo *f)
 {
-       classinfo *c = f->class;
-       int slot = f - c->fields;
-
-       if (c->field_annotations != NULL &&
-           c->field_annotations->size > slot) {
-               return c->field_annotations->data[slot];
+       classinfo              *c           = f->class;
+       int                     slot        = f - c->fields;
+       annotation_bytearray_t *ba          = NULL;
+       java_bytearray         *annotations = NULL;
+       
+       if (c->field_annotations != NULL && c->field_annotations->size > slot) {
+               ba = c->field_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;
 }
 #endif
 
index dce84cefefa0055cdd02ac2e635eda03bad435d3..7eb3df5a17f4c437d206fbc6f770c401e9e336d0 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: field.h 8268 2007-08-07 13:24:43Z twisti $
+   $Id: field.h 8315 2007-08-15 22:49:20Z panzi $
 */
 
 
@@ -77,7 +77,7 @@ classinfo *field_get_type(fieldinfo *f);
 void       field_free(fieldinfo *f);
 
 #if defined(ENABLE_ANNOTATIONS)
-annotation_bytearray_t *field_get_annotations(fieldinfo *f);
+java_bytearray *field_get_annotations(fieldinfo *f);
 #endif
 
 #if !defined(NDEBUG)
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
 
index af9930d54bc6ce18341379f56e453aa37fc84727..2935e79a62543fb174da8b6b139dc25db95c20cd 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: method.h 8295 2007-08-11 17:57:24Z michi $
+   $Id: method.h 8315 2007-08-15 22:49:20Z panzi $
 */
 
 
@@ -175,9 +175,9 @@ void method_break_assumption_monomorphic(methodinfo *m, method_worklist **wl);
 s4   method_count_implementations(methodinfo *m, classinfo *c, methodinfo **found);
 
 #if defined(ENABLE_ANNOTATIONS)
-annotation_bytearray_t *method_get_annotations(methodinfo *m);
-annotation_bytearray_t *method_get_parameterannotations(methodinfo *m);
-annotation_bytearray_t *method_get_annotationdefault(methodinfo *m);
+java_bytearray *method_get_annotations(methodinfo *m);
+java_bytearray *method_get_parameterannotations(methodinfo *m);
+java_bytearray *method_get_annotationdefault(methodinfo *m);
 #endif
 
 #if !defined(NDEBUG)