* src/vmcore/method.c (method_get_annotations): Always enable the
authortwisti <none@none>
Thu, 16 Aug 2007 15:54:38 +0000 (15:54 +0000)
committertwisti <none@none>
Thu, 16 Aug 2007 15:54:38 +0000 (15:54 +0000)
method, but return NULL for !ENABLE_ANNOTATIONS. This keeps code
calling this function simpler.
(method_get_parameterannotations): Likewise.
(method_get_annotationdefault): Likewise.

* src/vmcore/method.h (method_get_annotations): Removed
ENABLE_ANNOTATIONS.
(method_get_parameterannotations): Likewise.
(method_get_annotationdefault): Likewise.

* src/native/vm/reflect.c (reflect_constructor_new): Always call
method-annotations functions.
(reflect_field_new): Likewise.
(reflect_method_new): Likewise.

src/native/vm/reflect.c
src/vmcore/method.c
src/vmcore/method.h

index 4d31f365c7276a5c3aedcb5e91e3569053bccb8d..fa8d88066b62370a067732101ac149dc0dd8a1ad 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: reflect.c 8318 2007-08-16 10:05:34Z michi $
+   $Id: reflect.c 8322 2007-08-16 15:54:38Z twisti $
 
 */
 
@@ -83,8 +83,6 @@ java_lang_reflect_Constructor *reflect_constructor_new(methodinfo *m)
        java_handle_t                 *o;
        java_lang_reflect_Constructor *rc;
        int32_t                        slot;
-       java_handle_bytearray_t       *annotations          = NULL;
-       java_handle_bytearray_t       *parameterAnnotations = NULL;
 
        /* get declaring class */
 
@@ -105,22 +103,12 @@ 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);
        LLNI_field_set_val(rc, slot                , slot);
-       LLNI_field_set_ref(rc, annotations         , annotations);
-       LLNI_field_set_ref(rc, parameterAnnotations, parameterAnnotations);
+       LLNI_field_set_ref(rc, annotations         , method_get_annotations(m));
+       LLNI_field_set_ref(rc, parameterAnnotations, method_get_parameterannotations(m));
 
 #elif defined(WITH_CLASSPATH_SUN)
 
@@ -130,8 +118,8 @@ java_lang_reflect_Constructor *reflect_constructor_new(methodinfo *m)
        LLNI_field_set_val(rc, modifiers           , m->flags & ACC_CLASS_REFLECT_MASK);
        LLNI_field_set_val(rc, slot                , slot);
        LLNI_field_set_ref(rc, signature           , m->signature ? (java_lang_String *) javastring_new(m->signature) : NULL);
-       LLNI_field_set_ref(rc, annotations         , annotations);
-       LLNI_field_set_ref(rc, parameterAnnotations, parameterAnnotations);
+       LLNI_field_set_ref(rc, annotations         , method_get_annotations(m));
+       LLNI_field_set_ref(rc, parameterAnnotations, method_get_parameterannotations(m));
 
 #else
 # error unknown classpath configuration
@@ -154,7 +142,6 @@ java_lang_reflect_Field *reflect_field_new(fieldinfo *f)
        java_handle_t           *o;
        java_lang_reflect_Field *rf;
        int32_t                  slot;
-       java_handle_bytearray_t *annotations = NULL;
 
        /* get declaring class */
 
@@ -175,12 +162,6 @@ 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);
@@ -190,7 +171,7 @@ java_lang_reflect_Field *reflect_field_new(fieldinfo *f)
 
        LLNI_field_set_ref(rf, name          , _Jv_java_lang_String_intern((java_lang_String *) javastring_new(f->name)));
        LLNI_field_set_val(rf, slot          , slot);
-       LLNI_field_set_ref(rf, annotations   , annotations);
+       LLNI_field_set_ref(rf, annotations   , field_get_annotations(f));
 
 #elif defined(WITH_CLASSPATH_SUN)
 
@@ -204,7 +185,7 @@ java_lang_reflect_Field *reflect_field_new(fieldinfo *f)
        LLNI_field_set_val(rf, modifiers     , f->flags);
        LLNI_field_set_val(rf, slot          , slot);
        LLNI_field_set_ref(rf, signature     , f->signature ? (java_lang_String *) javastring_new(f->signature) : NULL);
-       LLNI_field_set_ref(rf, annotations   , annotations);
+       LLNI_field_set_ref(rf, annotations   , field_get_annotations(f));
 
 #else
 # error unknown classpath configuration
@@ -227,9 +208,6 @@ java_lang_reflect_Method *reflect_method_new(methodinfo *m)
        java_handle_t            *o;
        java_lang_reflect_Method *rm;
        int32_t                   slot;
-       java_handle_bytearray_t  *annotations          = NULL;
-       java_handle_bytearray_t  *parameterAnnotations = NULL;
-       java_handle_bytearray_t  *annotationDefault    = NULL;
 
        /* get declaring class */
 
@@ -250,20 +228,6 @@ 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);
@@ -273,9 +237,9 @@ java_lang_reflect_Method *reflect_method_new(methodinfo *m)
 
        LLNI_field_set_ref(rm, name                , _Jv_java_lang_String_intern((java_lang_String *) javastring_new(m->name)));
        LLNI_field_set_val(rm, slot                , slot);
-       LLNI_field_set_ref(rm, annotations         , annotations);
-       LLNI_field_set_ref(rm, parameterAnnotations, parameterAnnotations);
-       LLNI_field_set_ref(rm, annotationDefault   , annotationDefault);
+       LLNI_field_set_ref(rm, annotations         , method_get_annotations(m));
+       LLNI_field_set_ref(rm, parameterAnnotations, method_get_parameterannotations(m));
+       LLNI_field_set_ref(rm, annotationDefault   , method_get_annotationdefault(m));
 
 #elif defined(WITH_CLASSPATH_SUN)
 
@@ -291,9 +255,9 @@ java_lang_reflect_Method *reflect_method_new(methodinfo *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);
+       LLNI_field_set_ref(rm, annotations         , method_get_annotations(m));
+       LLNI_field_set_ref(rm, parameterAnnotations, method_get_parameterannotations(m));
+       LLNI_field_set_ref(rm, annotationDefault   , method_get_annotationdefault(m));
 
 #else
 # error unknown classpath configuration
index d4ff6655bc5e32e8493470f92c53b96a8a01b096..349bea811e3cb4f4f9831e21fee5edca91a31986 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: method.c 8318 2007-08-16 10:05:34Z michi $
+   $Id: method.c 8322 2007-08-16 15:54:38Z twisti $
 
 */
 
@@ -776,19 +776,23 @@ 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).
 
 *******************************************************************************/
 
-java_bytearray *method_get_annotations(methodinfo *m)
+java_handle_bytearray_t *method_get_annotations(methodinfo *m)
 {
-       classinfo              *c           = m->class;
-       int                     slot        = m - c->methods;
-       annotation_bytearray_t *ba          = NULL;
-       java_bytearray         *annotations = NULL;
+#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) {
                ba = c->method_annotations->data[slot];
@@ -803,6 +807,9 @@ java_bytearray *method_get_annotations(methodinfo *m)
        }
        
        return annotations;
+#else
+       return NULL;
+#endif
 }
 
 
@@ -812,12 +819,17 @@ java_bytearray *method_get_annotations(methodinfo *m)
 
 *******************************************************************************/
 
-java_bytearray *method_get_parameterannotations(methodinfo *m)
+java_handle_bytearray_t *method_get_parameterannotations(methodinfo *m)
 {
-       classinfo              *c                    = m->class;
-       int                     slot                 = m - c->methods;
-       annotation_bytearray_t *ba                   = NULL;
-       java_bytearray         *parameterAnnotations = NULL;
+#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) {
@@ -833,6 +845,9 @@ java_bytearray *method_get_parameterannotations(methodinfo *m)
        }
        
        return parameterAnnotations;
+#else
+       return NULL;
+#endif
 }
 
 
@@ -842,12 +857,17 @@ java_bytearray *method_get_parameterannotations(methodinfo *m)
 
 *******************************************************************************/
 
-java_bytearray *method_get_annotationdefault(methodinfo *m)
+java_handle_bytearray_t *method_get_annotationdefault(methodinfo *m)
 {
-       classinfo              *c                 = m->class;
-       int                     slot              = m - c->methods;
-       annotation_bytearray_t *ba                = NULL;
-       java_bytearray         *annotationDefault = NULL;
+#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) {
@@ -863,8 +883,10 @@ java_bytearray *method_get_annotationdefault(methodinfo *m)
        }
        
        return annotationDefault;
-}
+#else
+       return NULL;
 #endif
+}
 
 
 /* method_add_to_worklist ******************************************************
index 5c505cf663cdd96078b20abf01774bef3b22dcb3..1c10715b166c52314d77e7293e5f932adc44aed7 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: method.h 8318 2007-08-16 10:05:34Z michi $
+   $Id: method.h 8322 2007-08-16 15:54:38Z twisti $
 */
 
 
@@ -174,11 +174,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)
-java_bytearray *method_get_annotations(methodinfo *m);
-java_bytearray *method_get_parameterannotations(methodinfo *m);
-java_bytearray *method_get_annotationdefault(methodinfo *m);
-#endif
+java_handle_bytearray_t *method_get_annotations(methodinfo *m);
+java_handle_bytearray_t *method_get_parameterannotations(methodinfo *m);
+java_handle_bytearray_t *method_get_annotationdefault(methodinfo *m);
 
 #if !defined(NDEBUG)
 void method_printflags(methodinfo *m);