* src/lib/gnu/java/lang/reflect/Method.java
authorpanzi <none@none>
Wed, 22 Aug 2007 01:10:09 +0000 (01:10 +0000)
committerpanzi <none@none>
Wed, 22 Aug 2007 01:10:09 +0000 (01:10 +0000)
(declaredAnnotations): Added generic type parameters to Class.

* src/lib/gnu/java/lang/reflect/Field.java
(declaredAnnotations): Added generic type parameters to Class.

* src/lib/gnu/java/lang/reflect/Constructor.java
(declaredAnnotations): Added generic type parameters to Class.

* src/lib/gnu/sun/reflect/annotation/AnnotationParser.java: Fixed formatting.
* src/native/vm/gnu/sun_reflect_ConstantPool.c
(Java_sun_reflect_ConstantPool_getMemberRefInfoAt0):
Fixed formatting of log output.

* src/native/vm/gnu/java_lang_reflect_Method.c
(Java_java_lang_reflect_Method_getDefaultValue),
(Java_java_lang_reflect_Method_declaredAnnotations),
(Java_java_lang_reflect_Method_getParameterAnnotations):
Use LLNI_class_get macro.

* src/native/vm/gnu/java_lang_reflect_Field.c
(Java_java_lang_reflect_Method_declaredAnnotations):
Use LLNI_class_get macro.

* src/native/vm/gnu/java_lang_reflect_Constructor.c
(Java_java_lang_reflect_Method_declaredAnnotations),
(Java_java_lang_reflect_Method_getParameterAnnotations):
Use LLNI_class_get macro.

* src/native/vm/sun/jvm.c
(JVM_GetClassConstantPool): Fixed formatting of log output.

* src/native/vm/reflect.c
(reflect_get_declaredannotatios): Fixed comment.

* src/vmcore/class.h
(classinfo): Added comments for annottation fields.

* src/vmcore/annotation.h
(annotation_t), (element_value_t): Removed unused structs.

12 files changed:
src/lib/gnu/java/lang/reflect/Constructor.java
src/lib/gnu/java/lang/reflect/Field.java
src/lib/gnu/java/lang/reflect/Method.java
src/lib/gnu/sun/reflect/annotation/AnnotationParser.java
src/native/vm/gnu/java_lang_reflect_Constructor.c
src/native/vm/gnu/java_lang_reflect_Field.c
src/native/vm/gnu/java_lang_reflect_Method.c
src/native/vm/gnu/sun_reflect_ConstantPool.c
src/native/vm/reflect.c
src/native/vm/sun/jvm.c
src/vmcore/annotation.h
src/vmcore/class.h

index e984d3b99800bf645596b1c4b02bf6c0dc558831..c990fbc916af231a612c48288a506526bd28a0c7 100644 (file)
@@ -87,7 +87,7 @@ public final class Constructor<T>
   private int slot;
   private byte[] annotations = null;
   private byte[] parameterAnnotations = null;
-  private transient Map<Class, Annotation> declaredAnnotations = null;
+  private transient Map<Class<? extends Annotation>, Annotation> declaredAnnotations = null;
   
   private static final int CONSTRUCTOR_MODIFIERS
     = Modifier.PRIVATE | Modifier.PROTECTED | Modifier.PUBLIC;
@@ -416,11 +416,11 @@ public final class Constructor<T>
   /**
    * @since 1.5
    */
-  public Annotation[] getDeclaredAnnotations()  {
+  public Annotation[] getDeclaredAnnotations() {
     return declaredAnnotations().values().toArray(EMPTY_ANNOTATIONS_ARRAY);
   }
 
-  private synchronized native Map<Class, Annotation> declaredAnnotations();
+  private synchronized native Map<Class<? extends Annotation>, Annotation> declaredAnnotations();
   
   /**
    * Returns an array of arrays that represent the annotations on the formal
index c45ce4ae87dad135118f934c00394db788820cb0..e8889a859d9230edf88c098bcac4884f5df7799e 100644 (file)
@@ -86,7 +86,7 @@ extends AccessibleObject implements Member
   private String name;
   private int slot;
   private byte[] annotations = null;
-  private transient Map<Class, Annotation> declaredAnnotations = null;
+  private transient Map<Class<? extends Annotation>, Annotation> declaredAnnotations = null;
 
   private static final int FIELD_MODIFIERS
     = Modifier.FINAL | Modifier.PRIVATE | Modifier.PROTECTED
@@ -682,9 +682,9 @@ extends AccessibleObject implements Member
   /**
    * @since 1.5
    */
-  public Annotation[] getDeclaredAnnotations()  {
+  public Annotation[] getDeclaredAnnotations() {
     return declaredAnnotations().values().toArray(EMPTY_ANNOTATIONS_ARRAY);
   }
 
-  private synchronized native Map<Class, Annotation> declaredAnnotations();
+  private synchronized native Map<Class<? extends Annotation>, Annotation> declaredAnnotations();
 }
index fb7936eaeb46aef9c719a3a6e403a7f117984066..a6b9c3241533bdfb750ef7f6fd1f30b69a5f3b41 100644 (file)
@@ -88,7 +88,7 @@ extends AccessibleObject implements Member, GenericDeclaration
   private byte[] annotations          = null;
   private byte[] parameterAnnotations = null;
   private byte[] annotationDefault    = null;
-  private transient Map<Class, Annotation> declaredAnnotations = null;
+  private transient Map<Class<? extends Annotation>, Annotation> declaredAnnotations = null;
 
   private static final int METHOD_MODIFIERS
     = Modifier.ABSTRACT | Modifier.FINAL | Modifier.NATIVE
@@ -486,11 +486,11 @@ extends AccessibleObject implements Member, GenericDeclaration
   /**
    * @since 1.5
    */
-  public Annotation[] getDeclaredAnnotations()  {
+  public Annotation[] getDeclaredAnnotations() {
     return declaredAnnotations().values().toArray(EMPTY_ANNOTATIONS_ARRAY);
   }
 
-  private synchronized native Map<Class, Annotation> declaredAnnotations();
+  private synchronized native Map<Class<? extends Annotation>, Annotation> declaredAnnotations();
   
   /**
    * Returns an array of arrays that represent the annotations on the formal
index c745ad3a3bde20ca5f707a1f7f8b53d8674d5e36..fe361fb835b72837b05f93e61fddccceb3689789 100644 (file)
@@ -71,8 +71,8 @@ public class AnnotationParser {
     public static Annotation[][] parseParameterAnnotations(
                     byte[] parameterAnnotations,
                     ConstantPool constPool,
-                   Class container,
-                   int numParameters) {
+                    Class container,
+                    int numParameters) {
         if (parameterAnnotations == null)
             return new Annotation[numParameters][0];
 
@@ -453,10 +453,10 @@ public class AnnotationParser {
     private static Class<?> parseSig(String sig, Class container) {
         if (sig.equals("V")) {
             return void.class;
-       }
-       else {
+        }
+        else {
             return toClass(new FieldSignatureParser(container, sig).getFieldType());
-       }
+        }
     }
 
     static Class<?> toClass(Type o) {
index a513adb010015a178e07a8ba9dfada553ed9f16c..09e4b921675bbdd18e601a1cd376c72e7c47dfe9 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: java_lang_reflect_Constructor.c 8326 2007-08-16 17:45:49Z twisti $
+   $Id: java_lang_reflect_Constructor.c 8393 2007-08-22 01:10:09Z panzi $
 
 */
 
@@ -118,14 +118,16 @@ JNIEXPORT struct java_util_Map* JNICALL Java_java_lang_reflect_Constructor_decla
        struct java_util_Map    *declaredAnnotations = NULL;
        java_handle_bytearray_t *annotations         = NULL;
        java_lang_Class         *declaringClass      = NULL;
+       classinfo               *referer             = NULL;
 
        LLNI_field_get_ref(this, declaredAnnotations, declaredAnnotations);
 
        if (declaredAnnotations == NULL) {
                LLNI_field_get_val(this, annotations, annotations);
                LLNI_field_get_ref(this, clazz, declaringClass);
+               LLNI_class_get(this, referer);
 
-               declaredAnnotations = reflect_get_declaredannotatios(annotations, declaringClass, o->vftbl->class);
+               declaredAnnotations = reflect_get_declaredannotatios(annotations, declaringClass, referer);
 
                LLNI_field_set_ref(this, declaredAnnotations, declaredAnnotations);
        }
@@ -145,12 +147,14 @@ JNIEXPORT java_handle_objectarray_t* JNICALL Java_java_lang_reflect_Constructor_
        java_handle_bytearray_t *parameterAnnotations = NULL;
        int32_t                  slot                 = -1;
        java_lang_Class         *declaringClass       = NULL;
+       classinfo               *referer              = NULL;
 
        LLNI_field_get_ref(this, parameterAnnotations, parameterAnnotations);
        LLNI_field_get_val(this, slot, slot);
        LLNI_field_get_ref(this, clazz, declaringClass);
+       LLNI_class_get(this, referer);
 
-       return reflect_get_parameterannotations((java_handle_t*)parameterAnnotations, slot, declaringClass, o->vftbl->class);
+       return reflect_get_parameterannotations((java_handle_t*)parameterAnnotations, slot, declaringClass, referer);
 }
 #endif
 
index 17f78367973352e45b020f0e7176be2e0ee2dfe0..e79dce6957c21af3b95e39d10ca9fda137280088 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: java_lang_reflect_Field.c 8343 2007-08-17 21:39:32Z michi $
+   $Id: java_lang_reflect_Field.c 8393 2007-08-22 01:10:09Z panzi $
 
 */
 
@@ -1257,14 +1257,16 @@ JNIEXPORT struct java_util_Map* JNICALL Java_java_lang_reflect_Field_declaredAnn
        struct java_util_Map    *declaredAnnotations = NULL;
        java_handle_bytearray_t *annotations         = NULL;
        java_lang_Class         *declaringClass      = NULL;
+       classinfo               *referer             = NULL;
 
        LLNI_field_get_ref(this, declaredAnnotations, declaredAnnotations);
 
        if (declaredAnnotations == NULL) {
                LLNI_field_get_val(this, annotations, annotations);
                LLNI_field_get_ref(this, clazz, declaringClass);
+               LLNI_class_get(this, referer);
 
-               declaredAnnotations = reflect_get_declaredannotatios(annotations, declaringClass, o->vftbl->class);
+               declaredAnnotations = reflect_get_declaredannotatios(annotations, declaringClass, referer);
 
                LLNI_field_set_ref(this, declaredAnnotations, declaredAnnotations);
        }
index e8849592467bbee1101da8c5c91ae7806f72eda9..fc916c985a0e5c902591a08e3bae463a987872bc 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: java_lang_reflect_Method.c 8343 2007-08-17 21:39:32Z michi $
+   $Id: java_lang_reflect_Method.c 8393 2007-08-22 01:10:09Z panzi $
 
 */
 
@@ -233,6 +233,7 @@ JNIEXPORT struct java_lang_Object* JNICALL Java_java_lang_reflect_Method_getDefa
        sun_reflect_ConstantPool *constantPool    = NULL;
        java_handle_t            *o               = (java_handle_t*)this;
        java_lang_Class          *constantPoolOop = NULL;
+       classinfo                *referer         = NULL;
 
        if (this == NULL) {
                exceptions_throw_nullpointerexception();
@@ -263,15 +264,16 @@ JNIEXPORT struct java_lang_Object* JNICALL Java_java_lang_reflect_Method_getDefa
                        return NULL;
                }
 
+               LLNI_class_get(this, referer);
+
                m_parseAnnotationDefault = class_resolveclassmethod(
                        class_sun_reflect_annotation_AnnotationParser,
                        utf_parseAnnotationDefault,
                        utf_desc,
-                       o->vftbl->class,
+                       referer,
                        true);
 
-               if (m_parseAnnotationDefault == NULL)
-               {
+               if (m_parseAnnotationDefault == NULL) {
                        /* method not found */
                        return NULL;
                }
@@ -294,14 +296,16 @@ JNIEXPORT struct java_util_Map* JNICALL Java_java_lang_reflect_Method_declaredAn
        struct java_util_Map    *declaredAnnotations = NULL;
        java_handle_bytearray_t *annotations         = NULL;
        java_lang_Class         *declaringClass      = NULL;
+       classinfo               *referer             = NULL;
 
        LLNI_field_get_ref(this, declaredAnnotations, declaredAnnotations);
 
        if (declaredAnnotations == NULL) {
                LLNI_field_get_val(this, annotations, annotations);
                LLNI_field_get_ref(this, clazz, declaringClass);
+               LLNI_class_get(this, referer);
 
-               declaredAnnotations = reflect_get_declaredannotatios(annotations, declaringClass, o->vftbl->class);
+               declaredAnnotations = reflect_get_declaredannotatios(annotations, declaringClass, referer);
 
                LLNI_field_set_ref(this, declaredAnnotations, declaredAnnotations);
        }
@@ -321,12 +325,14 @@ JNIEXPORT java_handle_objectarray_t* JNICALL Java_java_lang_reflect_Method_getPa
        java_handle_bytearray_t *parameterAnnotations = NULL;
        int32_t                  slot                 = -1;
        java_lang_Class         *declaringClass       = NULL;
+       classinfo               *referer              = NULL;
 
        LLNI_field_get_ref(this, parameterAnnotations, parameterAnnotations);
        LLNI_field_get_val(this, slot, slot);
        LLNI_field_get_ref(this, clazz, declaringClass);
+       LLNI_class_get(this, referer);
 
-       return reflect_get_parameterannotations((java_handle_t*)parameterAnnotations, slot, declaringClass, o->vftbl->class);
+       return reflect_get_parameterannotations((java_handle_t*)parameterAnnotations, slot, declaringClass, referer);
 }
 #endif
 
index 9b003f25a620292a44d8b950db99bb1078771b94..bb60dcfd685ad59428c3ba0bee59ba8ea41c5813 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: sun_reflect_ConstantPool.c 8346 2007-08-17 22:13:31Z twisti $
+   $Id: sun_reflect_ConstantPool.c 8393 2007-08-22 01:10:09Z panzi $
 
 */
 
@@ -265,7 +265,7 @@ JNIEXPORT struct java_lang_reflect_Field* JNICALL Java_sun_reflect_ConstantPool_
  */
 JNIEXPORT java_handle_objectarray_t* JNICALL Java_sun_reflect_ConstantPool_getMemberRefInfoAt0(JNIEnv *env, struct sun_reflect_ConstantPool* this, struct java_lang_Object* jcpool, int32_t index)
 {
-       log_println("Java_sun_reflect_ConstantPool_getMemberRefInfoAt0: jcpool=%p, index=%d, IMPLEMENT ME!", jcpool, index);
+       log_println("Java_sun_reflect_ConstantPool_getMemberRefInfoAt0(env=%p, jcpool=%p, index=%d): IMPLEMENT ME!", env, jcpool, index);
        return NULL;
 }
 
index 695e10c1ce6d793f812dd25f46e2095cb8480f0b..ce6cb2cc4ea2783efd160df954be16c562d4d4c6 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: reflect.c 8357 2007-08-19 22:59:43Z twisti $
+   $Id: reflect.c 8393 2007-08-22 01:10:09Z panzi $
 
 */
 
@@ -269,8 +269,8 @@ java_lang_reflect_Method *reflect_method_new(methodinfo *m)
 #if defined(WITH_CLASSPATH_GNU) && defined(ENABLE_ANNOTATIONS)
 /* reflect_get_declaredannotatios *********************************************
 
-   Returns a java.util.Map<Class, Annotation> of the declared
-   annotations.
+   Returns a java.util.Map<Class<? extends Annotation>, Annotation>
+   of the declared annotations.
 
 *******************************************************************************/
 
index 80607170255097674795b742d71c095039f24516..b39e63ee64e469c26777579cbcf2771ceacc9eaa 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: jvm.c 8387 2007-08-21 15:37:47Z twisti $
+   $Id: jvm.c 8393 2007-08-22 01:10:09Z panzi $
 
 */
 
@@ -1240,9 +1240,7 @@ jobject JVM_GetClassConstantPool(JNIEnv *env, jclass cls)
        sun_reflect_ConstantPool *constantPool    = NULL;
        java_lang_Object         *constantPoolOop = (java_lang_Object*)cls;
        
-       TRACEJVMCALLS("JVM_GetClassConstantPool: cls=%p", cls);
-
-       assert(cls != NULL);
+       TRACEJVMCALLS("JVM_GetClassConstantPool(env=%p, cls=%p)", env, cls);
 
        constantPool = 
                (sun_reflect_ConstantPool*)native_new_and_init(
@@ -1257,7 +1255,7 @@ jobject JVM_GetClassConstantPool(JNIEnv *env, jclass cls)
 
        return (jobject)constantPool;
 #else
-       log_println("JVM_GetClassConstantPool: cls=%p, not implemented in this configuration!", cls);
+       log_println("JVM_GetClassConstantPool(env=%p, cls=%p): not implemented in this configuration!", env, cls);
        return NULL;
 #endif
 }
index 3d2f4b768d77619e8fb9c7c7e6b1ef005507918b..c224ebe8494fd97782b7f4da4f85b76eeea95f37 100644 (file)
@@ -54,6 +54,7 @@ struct annotation_bytearray_t {
        uint8_t  data[1];
 };
 
+
 /* annotation_bytearrays ******************************************************/
 
 struct annotation_bytearrays_t {
@@ -61,21 +62,6 @@ struct annotation_bytearrays_t {
        annotation_bytearray_t *data[1];
 };
 
-/* annotation *****************************************************************/
-
-struct annotation_t {
-       utf             *type;
-       s4               element_valuescount;
-       element_value_t *element_values;
-};
-
-/* element_value **************************************************************/
-
-struct element_value_t {
-       utf *name;
-       u1   tag;
-};
-
 
 /* function prototypes ********************************************************/
 
index 9054cc5a33d950fc065fdad638d704fae8e7f843..6a812ef3ba176333c70d13fd11655e3d1515095e 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: class.h 8387 2007-08-21 15:37:47Z twisti $
+   $Id: class.h 8393 2007-08-22 01:10:09Z panzi $
 
 */
 
@@ -147,13 +147,20 @@ struct classinfo {                /* class structure                          */
 #if defined(ENABLE_JAVASE)
        utf        *signature;        /* Signature attribute                      */
 #if defined(ENABLE_ANNOTATIONS)
-       annotation_bytearray_t  *annotations;
+        /* all the anntation attributes are NULL (and not a zero length array)
+          if there is nothing */
+       annotation_bytearray_t  *annotations; /* annotations of this class        */
        
-       annotation_bytearrays_t *method_annotations;
-       annotation_bytearrays_t *method_parameterannotations;
-       annotation_bytearrays_t *method_annotationdefaults;
-
-       annotation_bytearrays_t *field_annotations;
+       annotation_bytearrays_t *method_annotations; /* array of annotations for  */
+                                     /* the methods                              */
+       annotation_bytearrays_t *method_parameterannotations; /* array of         */
+                                     /* parameter annotations for the methods    */
+       annotation_bytearrays_t *method_annotationdefaults; /* array for          */
+                                     /* annotation default values for the        */
+                                     /* methods                                  */
+
+       annotation_bytearrays_t *field_annotations; /* array of annotations for   */
+                                     /* the fields                               */
 #endif
 #endif
        classloader *classloader;       /* NULL for bootstrap classloader         */