* src/native/vm/gnu/java_lang_reflect_Method.c: Fixed merge problem in
authormichi <none@none>
Fri, 10 Aug 2007 09:20:04 +0000 (09:20 +0000)
committermichi <none@none>
Fri, 10 Aug 2007 09:20:04 +0000 (09:20 +0000)
previous revision 8284.

* src/native/vm/gnu/java_lang_reflect_Constructor.c: Likewise.

src/native/vm/gnu/java_lang_reflect_Constructor.c
src/native/vm/gnu/java_lang_reflect_Method.c

index 8790e35e8e87e1de53af054e2c524ef0cd6aa304..0c020bf8b1e5b7382bb661292cf4dbfd1b344e38 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: java_lang_reflect_Constructor.c 8284 2007-08-10 08:58:39Z michi $
+   $Id: java_lang_reflect_Constructor.c 8285 2007-08-10 09:20:04Z michi $
 
 */
 
 #include <assert.h>
 #include <stdlib.h>
 
+#if defined(ENABLE_ANNOTATIONS)
+#include "vm/vm.h"
+#endif
+
 #include "vm/types.h"
 
 #include "native/jni.h"
 #include "native/include/java_lang_String.h"
 #include "native/include/java_lang_reflect_Constructor.h"
 
+#if defined(ENABLE_ANNOTATIONS)
+#include "native/include/sun_reflect_ConstantPool.h"
+#include "native/vm/reflect.h"
+#endif
+
 #include "native/vm/java_lang_reflect_Constructor.h"
 
 #include "vmcore/utf8.h"
 /* native methods implemented by this file ************************************/
 
 static JNINativeMethod methods[] = {
-       { "getModifiersInternal", "()I",                                                       (void *) (ptrint) &_Jv_java_lang_reflect_Constructor_getModifiers      },
-       { "getParameterTypes",    "()[Ljava/lang/Class;",                                      (void *) (ptrint) &_Jv_java_lang_reflect_Constructor_getParameterTypes },
-       { "getExceptionTypes",    "()[Ljava/lang/Class;",                                      (void *) (ptrint) &_Jv_java_lang_reflect_Constructor_getExceptionTypes },
-       { "constructNative",      "([Ljava/lang/Object;Ljava/lang/Class;I)Ljava/lang/Object;", (void *) (ptrint) &Java_java_lang_reflect_Constructor_constructNative  },
-       { "getSignature",         "()Ljava/lang/String;",                                      (void *) (ptrint) &_Jv_java_lang_reflect_Constructor_getSignature      },
+       { "getModifiersInternal",    "()I",                                                       (void *) (ptrint) &_Jv_java_lang_reflect_Constructor_getModifiers        },
+       { "getParameterTypes",       "()[Ljava/lang/Class;",                                      (void *) (ptrint) &_Jv_java_lang_reflect_Constructor_getParameterTypes   },
+       { "getExceptionTypes",       "()[Ljava/lang/Class;",                                      (void *) (ptrint) &_Jv_java_lang_reflect_Constructor_getExceptionTypes   },
+       { "constructNative",         "([Ljava/lang/Object;Ljava/lang/Class;I)Ljava/lang/Object;", (void *) (ptrint) &Java_java_lang_reflect_Constructor_constructNative    },
+       { "getSignature",            "()Ljava/lang/String;",                                      (void *) (ptrint) &_Jv_java_lang_reflect_Constructor_getSignature        },
+#if defined(ENABLE_ANNOTATIONS)
+       { "declaredAnnotations",     "()Ljava/util/Map;",                                         (void *) (ptrint) &Java_java_lang_reflect_Constructor_declaredAnnotations     },
+       { "getParameterAnnotations", "()[[Ljava/lang/annotation/Annotation;",                     (void *) (ptrint) &Java_java_lang_reflect_Constructor_getParameterAnnotations },
+#endif
 };
 
 
@@ -91,6 +104,43 @@ JNIEXPORT java_lang_Object* JNICALL Java_java_lang_reflect_Constructor_construct
 }
 
 
+#if defined(ENABLE_ANNOTATIONS)
+/*
+ * Class:     java/lang/reflect/Constructor
+ * Method:    declaredAnnotations
+ * Signature: ()Ljava/util/Map;
+ */
+JNIEXPORT struct java_util_Map* JNICALL Java_java_lang_reflect_Constructor_declaredAnnotations(JNIEnv *env, struct java_lang_reflect_Constructor* this)
+{
+       java_objectheader *o = (java_objectheader*)this;
+
+       if (this == NULL) {
+               exceptions_throw_nullpointerexception();
+               return NULL;
+       }
+
+       return reflect_get_declaredannotatios(&(this->declaredAnnotations), this->annotations, this->clazz, o->vftbl->class);
+}
+
+
+/*
+ * Class:     java/lang/reflect/Constructor
+ * Method:    getParameterAnnotations
+ * Signature: ()[[Ljava/lang/annotation/Annotation;
+ */
+JNIEXPORT java_objectarray* JNICALL Java_java_lang_reflect_Constructor_getParameterAnnotations(JNIEnv *env, struct java_lang_reflect_Constructor* this)
+{
+       java_objectheader *o = (java_objectheader*)this;
+
+       if (this == NULL) {
+               exceptions_throw_nullpointerexception();
+               return NULL;
+       }
+
+       return reflect_get_parameterannotations((java_objectheader*)this->parameterAnnotations, this->slot, this->clazz, o->vftbl->class);
+}
+#endif
+
 /*
  * These are local overrides for various environment variables in Emacs.
  * Please do not remove this and leave it at the end of the file, where
index e89ad411481310079e1030321679c202c09bfa73..61b7ea0dd25e71befcacf215f4084f8f7e8e9858 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: java_lang_reflect_Method.c 8284 2007-08-10 08:58:39Z michi $
+   $Id: java_lang_reflect_Method.c 8285 2007-08-10 09:20:04Z michi $
 
 */
 
 
 #include <assert.h>
 
+#if defined(ENABLE_ANNOTATIONS)
+#include "vm/vm.h"
+#endif
+
 #include "vm/types.h"
 
 #include "native/jni.h"
 #include "native/include/java_lang_Class.h"
 #include "native/include/java_lang_String.h"
 
+#if defined(ENABLE_ANNOTATIONS)
+#include "native/include/sun_reflect_ConstantPool.h"
+#include "native/vm/reflect.h"
+#endif
+
 #include "native/include/java_lang_reflect_Method.h"
 
 #include "native/vm/java_lang_reflect_Method.h"
 /* native methods implemented by this file ************************************/
 
 static JNINativeMethod methods[] = {
-       { "getModifiersInternal", "()I",                                                                         (void *) (ptrint) &Java_java_lang_reflect_Method_getModifiersInternal },
-       { "getReturnType",        "()Ljava/lang/Class;",                                                         (void *) (ptrint) &Java_java_lang_reflect_Method_getReturnType        },
-       { "getParameterTypes",    "()[Ljava/lang/Class;",                                                        (void *) (ptrint) &Java_java_lang_reflect_Method_getParameterTypes    },
-       { "getExceptionTypes",    "()[Ljava/lang/Class;",                                                        (void *) (ptrint) &Java_java_lang_reflect_Method_getExceptionTypes    },
-       { "invokeNative",         "(Ljava/lang/Object;[Ljava/lang/Object;Ljava/lang/Class;I)Ljava/lang/Object;", (void *) (ptrint) &Java_java_lang_reflect_Method_invokeNative         },
-       { "getSignature",         "()Ljava/lang/String;",                                                        (void *) (ptrint) &Java_java_lang_reflect_Method_getSignature         },
+       { "getModifiersInternal",    "()I",                                                                         (void *) (ptrint) &Java_java_lang_reflect_Method_getModifiersInternal    },
+       { "getReturnType",           "()Ljava/lang/Class;",                                                         (void *) (ptrint) &Java_java_lang_reflect_Method_getReturnType           },
+       { "getParameterTypes",       "()[Ljava/lang/Class;",                                                        (void *) (ptrint) &Java_java_lang_reflect_Method_getParameterTypes       },
+       { "getExceptionTypes",       "()[Ljava/lang/Class;",                                                        (void *) (ptrint) &Java_java_lang_reflect_Method_getExceptionTypes       },
+       { "invokeNative",            "(Ljava/lang/Object;[Ljava/lang/Object;Ljava/lang/Class;I)Ljava/lang/Object;", (void *) (ptrint) &Java_java_lang_reflect_Method_invokeNative            },
+       { "getSignature",            "()Ljava/lang/String;",                                                        (void *) (ptrint) &Java_java_lang_reflect_Method_getSignature            },
+#if defined(ENABLE_ANNOTATIONS)
+       { "getDefaultValue",         "()Ljava/lang/Object;",                                                        (void *) (ptrint) &Java_java_lang_reflect_Method_getDefaultValue         },
+       { "declaredAnnotations",     "()Ljava/util/Map;",                                                           (void *) (ptrint) &Java_java_lang_reflect_Method_declaredAnnotations     },
+       { "getParameterAnnotations", "()[[Ljava/lang/annotation/Annotation;",                                       (void *) (ptrint) &Java_java_lang_reflect_Method_getParameterAnnotations },
+#endif
 };
 
 
@@ -205,6 +219,104 @@ JNIEXPORT java_lang_String* JNICALL Java_java_lang_reflect_Method_getSignature(J
        return (java_lang_String *) o;
 }
 
+#if defined(ENABLE_ANNOTATIONS)
+/*
+ * Class:     java/lang/reflect/Method
+ * Method:    getDefaultValue
+ * Signature: ()Ljava/lang/Object;
+ */
+JNIEXPORT struct java_lang_Object* JNICALL Java_java_lang_reflect_Method_getDefaultValue(JNIEnv *env, struct java_lang_reflect_Method* this)
+{
+       static methodinfo        *m_parseAnnotationDefault   = NULL;
+       utf                      *utf_parseAnnotationDefault = NULL;
+       utf                      *utf_desc     = NULL;
+       sun_reflect_ConstantPool *constantPool = NULL;
+       java_objectheader        *o            = (java_objectheader*)this;
+
+       if (this == NULL) {
+               exceptions_throw_nullpointerexception();
+               return NULL;
+       }
+
+       constantPool = 
+               (sun_reflect_ConstantPool*)native_new_and_init(
+                       class_sun_reflect_ConstantPool);
+       
+       if(constantPool == NULL) {
+               /* out of memory */
+               return NULL;
+       }
+
+       constantPool->constantPoolOop = (java_lang_Object*)this->clazz;
+
+       /* only resolve the method the first time */
+       if (m_parseAnnotationDefault == NULL) {
+               utf_parseAnnotationDefault = utf_new_char("parseAnnotationDefault");
+               utf_desc = utf_new_char(
+                       "(Ljava/lang/reflect/Method;[BLsun/reflect/ConstantPool;)"
+                       "Ljava/lang/Object;");
+
+               if (utf_parseAnnotationDefault == NULL || utf_desc == NULL) {
+                       /* out of memory */
+                       return NULL;
+               }
+
+               m_parseAnnotationDefault = class_resolveclassmethod(
+                       class_sun_reflect_annotation_AnnotationParser,
+                       utf_parseAnnotationDefault,
+                       utf_desc,
+                       o->vftbl->class,
+                       true);
+
+               if (m_parseAnnotationDefault == NULL)
+               {
+                       /* method not found */
+                       return NULL;
+               }
+       }
+
+       return (java_lang_Object*)vm_call_method(
+               m_parseAnnotationDefault, NULL,
+               this, this->annotationDefault, constantPool);
+}
+
+
+/*
+ * Class:     java/lang/reflect/Method
+ * Method:    declaredAnnotations
+ * Signature: ()Ljava/util/Map;
+ */
+JNIEXPORT struct java_util_Map* JNICALL Java_java_lang_reflect_Method_declaredAnnotations(JNIEnv *env, struct java_lang_reflect_Method* this)
+{
+       java_objectheader *o = (java_objectheader*)this;
+
+       if (this == NULL) {
+               exceptions_throw_nullpointerexception();
+               return NULL;
+       }
+
+       return reflect_get_declaredannotatios(&(this->declaredAnnotations), this->annotations, this->clazz, o->vftbl->class);
+}
+
+
+/*
+ * Class:     java/lang/reflect/Method
+ * Method:    getParameterAnnotations
+ * Signature: ()[[Ljava/lang/annotation/Annotation;
+ */
+JNIEXPORT java_objectarray* JNICALL Java_java_lang_reflect_Method_getParameterAnnotations(JNIEnv *env, struct java_lang_reflect_Method* this)
+{
+       java_objectheader *o = (java_objectheader*)this;
+
+       if (this == NULL) {
+               exceptions_throw_nullpointerexception();
+               return NULL;
+       }
+
+       return reflect_get_parameterannotations((java_objectheader*)this->parameterAnnotations, this->slot, this->clazz, o->vftbl->class);
+}
+#endif
+
 
 /*
  * These are local overrides for various environment variables in Emacs.