Merged revisions 8299-8320 via svnmerge from
[cacao.git] / src / native / vm / gnu / java_lang_reflect_Constructor.c
index 3a82a63aab28b0e2bc8cce0fe2845118083386d2..605a2b9ae5209ca800151bf257918ccb5f3890a3 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: java_lang_reflect_Constructor.c 8295 2007-08-11 17:57:24Z michi $
+   $Id: java_lang_reflect_Constructor.c 8318 2007-08-16 10:05:34Z michi $
 
 */
 
@@ -34,6 +34,7 @@
 
 #if defined(ENABLE_ANNOTATIONS)
 #include "vm/vm.h"
+#include "vm/exceptions.h"
 #endif
 
 #include "vm/types.h"
@@ -93,7 +94,7 @@ void _Jv_java_lang_reflect_Constructor_init(void)
  * Method:    constructNative
  * Signature: ([Ljava/lang/Object;Ljava/lang/Class;I)Ljava/lang/Object;
  */
-JNIEXPORT java_lang_Object* JNICALL Java_java_lang_reflect_Constructor_constructNative(JNIEnv *env, java_lang_reflect_Constructor *this, java_objectarray *args, java_lang_Class *declaringClass, s4 slot)
+JNIEXPORT java_lang_Object* JNICALL Java_java_lang_reflect_Constructor_constructNative(JNIEnv *env, java_lang_reflect_Constructor *this, java_handle_objectarray_t *args, java_lang_Class *declaringClass, s4 slot)
 {
        /* just to be sure */
 
@@ -112,14 +113,28 @@ JNIEXPORT java_lang_Object* JNICALL Java_java_lang_reflect_Constructor_construct
  */
 JNIEXPORT struct java_util_Map* JNICALL Java_java_lang_reflect_Constructor_declaredAnnotations(JNIEnv *env, struct java_lang_reflect_Constructor* this)
 {
-       java_handle_t *o = (java_handle_t*)this;
+       java_handle_t        *o                   = (java_handle_t*)this;
+       struct java_util_Map *declaredAnnotations = NULL;
+       java_bytearray       *annotations         = NULL;
+       java_lang_Class      *declaringClass      = NULL;
 
        if (this == NULL) {
                exceptions_throw_nullpointerexception();
                return NULL;
        }
+       
+       LLNI_field_get_ref(this, declaredAnnotations, declaredAnnotations);
 
-       return reflect_get_declaredannotatios(&(this->declaredAnnotations), this->annotations, this->clazz, o->vftbl->class);
+       if (declaredAnnotations == NULL) {
+               LLNI_field_get_val(this, annotations, annotations);
+               LLNI_field_get_ref(this, clazz, declaringClass);
+
+               declaredAnnotations = reflect_get_declaredannotatios(annotations, declaringClass, o->vftbl->class);
+
+               LLNI_field_set_ref(this, declaredAnnotations, declaredAnnotations);
+       }
+
+       return declaredAnnotations;
 }
 
 
@@ -128,16 +143,23 @@ JNIEXPORT struct java_util_Map* JNICALL Java_java_lang_reflect_Constructor_decla
  * 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)
+JNIEXPORT java_handle_objectarray_t* JNICALL Java_java_lang_reflect_Constructor_getParameterAnnotations(JNIEnv *env, struct java_lang_reflect_Constructor* this)
 {
-       java_handle_t *o = (java_handle_t*)this;
+       java_handle_t   *o                    = (java_handle_t*)this;
+       java_bytearray  *parameterAnnotations = NULL;
+       int32_t          slot                 = -1;
+       java_lang_Class *declaringClass       = NULL;
 
        if (this == NULL) {
                exceptions_throw_nullpointerexception();
                return NULL;
        }
 
-       return reflect_get_parameterannotations((java_handle_t*)this->parameterAnnotations, this->slot, this->clazz, o->vftbl->class);
+       LLNI_field_get_ref(this, parameterAnnotations, parameterAnnotations);
+       LLNI_field_get_val(this, slot, slot);
+       LLNI_field_get_ref(this, clazz, declaringClass);
+
+       return reflect_get_parameterannotations((java_handle_t*)parameterAnnotations, slot, declaringClass, o->vftbl->class);
 }
 #endif