X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=src%2Fnative%2Fvm%2Fgnu%2Fjava_lang_reflect_Constructor.c;h=c12b9eb213acb5d245a087196e57e74922c4fbb9;hb=9f859ad50d3d5d98c185d40b86b2179bc4dc9aeb;hp=f13cde7e5d6da5eb8384dace83899e99988ce233;hpb=982c16354da900000d08974e0f3beff3ee08d068;p=cacao.git diff --git a/src/native/vm/gnu/java_lang_reflect_Constructor.c b/src/native/vm/gnu/java_lang_reflect_Constructor.c index f13cde7e5..c12b9eb21 100644 --- a/src/native/vm/gnu/java_lang_reflect_Constructor.c +++ b/src/native/vm/gnu/java_lang_reflect_Constructor.c @@ -22,8 +22,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: java_lang_reflect_Constructor.c 7720 2007-04-16 15:49:09Z twisti $ - */ @@ -32,139 +30,131 @@ #include #include +#if defined(ENABLE_ANNOTATIONS) +#include "vm/vm.h" +#include "vm/exceptions.h" +#endif + #include "vm/types.h" #include "native/jni.h" +#include "native/llni.h" #include "native/native.h" + #include "native/include/java_lang_Class.h" #include "native/include/java_lang_Object.h" #include "native/include/java_lang_String.h" #include "native/include/java_lang_reflect_Constructor.h" -#include "toolbox/logging.h" +#if defined(ENABLE_ANNOTATIONS) +# include "native/include/sun_reflect_ConstantPool.h" -#include "vm/builtin.h" -#include "vm/exceptions.h" -#include "vm/access.h" -#include "vm/stringlocal.h" +# include "native/vm/reflect.h" +#endif -#include "vmcore/class.h" -#include "vmcore/method.h" +#include "native/vm/java_lang_reflect_Constructor.h" +#include "vmcore/utf8.h" -/* - * Class: java/lang/reflect/Constructor - * Method: getModifiersInternal - * Signature: ()I - */ -JNIEXPORT s4 JNICALL Java_java_lang_reflect_Constructor_getModifiersInternal(JNIEnv *env, java_lang_reflect_Constructor *this) -{ - classinfo *c; - methodinfo *m; - c = (classinfo *) (this->clazz); - m = &(c->methods[this->slot]); +/* native methods implemented by this file ************************************/ - return m->flags; -} +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 }, +#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 +}; -/* - * Class: java/lang/reflect/Constructor - * Method: getParameterTypes - * Signature: ()[Ljava/lang/Class; - */ -JNIEXPORT java_objectarray* JNICALL Java_java_lang_reflect_Constructor_getParameterTypes(JNIEnv *env, java_lang_reflect_Constructor *this) +/* _Jv_java_lang_reflect_Constructor_init ************************************** + + Register native functions. + +*******************************************************************************/ + +void _Jv_java_lang_reflect_Constructor_init(void) { - classinfo *c; - methodinfo *m; + utf *u; - c = (classinfo *) this->clazz; - m = &(c->methods[this->slot]); + u = utf_new_char("java/lang/reflect/Constructor"); - return method_get_parametertypearray(m); + native_method_register(u, methods, NATIVE_METHODS_COUNT); } /* * Class: java/lang/reflect/Constructor - * Method: getExceptionTypes - * Signature: ()[Ljava/lang/Class; + * Method: constructNative + * Signature: ([Ljava/lang/Object;Ljava/lang/Class;I)Ljava/lang/Object; */ -JNIEXPORT java_objectarray* JNICALL Java_java_lang_reflect_Constructor_getExceptionTypes(JNIEnv *env, java_lang_reflect_Constructor *this) +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) { - classinfo *c; - methodinfo *m; + /* just to be sure */ - c = (classinfo *) this->clazz; - m = &(c->methods[this->slot]); + assert(LLNI_field_direct(this, clazz) == declaringClass); + assert(LLNI_field_direct(this, slot) == slot); - return method_get_exceptionarray(m); + return _Jv_java_lang_reflect_Constructor_newInstance(env, this, args); } +#if defined(ENABLE_ANNOTATIONS) /* * Class: java/lang/reflect/Constructor - * Method: constructNative - * Signature: ([Ljava/lang/Object;)Ljava/lang/Object; + * Method: declaredAnnotations + * Signature: ()Ljava/util/Map; */ -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 struct java_util_Map* JNICALL Java_java_lang_reflect_Constructor_declaredAnnotations(JNIEnv *env, java_lang_reflect_Constructor *this) { - classinfo *c; - methodinfo *m; - java_objectheader *o; + java_handle_t *o = (java_handle_t*)this; + struct java_util_Map *declaredAnnotations = NULL; + java_handle_bytearray_t *annotations = NULL; + java_lang_Class *declaringClass = NULL; + classinfo *referer = NULL; - c = (classinfo *) declaringClass; - m = &(c->methods[this->slot]); + LLNI_field_get_ref(this, declaredAnnotations, declaredAnnotations); - /* check method access */ + if (declaredAnnotations == NULL) { + LLNI_field_get_val(this, annotations, annotations); + LLNI_field_get_ref(this, clazz, declaringClass); + LLNI_class_get(this, referer); - /* check if we should bypass security checks (AccessibleObject) */ + declaredAnnotations = reflect_get_declaredannotatios(annotations, declaringClass, referer); - if (this->flag == false) { - if (!access_check_member(c, m->flags, 1)) - return NULL; + LLNI_field_set_ref(this, declaredAnnotations, declaredAnnotations); } - /* create object */ - - o = builtin_new(c); - - if (o == NULL) - return NULL; - - /* call initializer */ - - (void) _Jv_jni_invokeNative(m, o, args); - - return (java_lang_Object *) o; + return declaredAnnotations; } /* * Class: java/lang/reflect/Constructor - * Method: getSignature - * Signature: ()Ljava/lang/String; + * Method: getParameterAnnotations + * Signature: ()[[Ljava/lang/annotation/Annotation; */ -JNIEXPORT java_lang_String* JNICALL Java_java_lang_reflect_Constructor_getSignature(JNIEnv *env, java_lang_reflect_Constructor *this) +JNIEXPORT java_handle_objectarray_t* JNICALL Java_java_lang_reflect_Constructor_getParameterAnnotations(JNIEnv *env, java_lang_reflect_Constructor *this) { - classinfo *c; - methodinfo *m; - java_objectheader *o; - - c = (classinfo *) this->clazz; - m = &(c->methods[this->slot]); - - if (m->signature == NULL) - return NULL; - - o = javastring_new(m->signature); - - /* in error case o is NULL */ - - return (java_lang_String *) o; + java_handle_t *o = (java_handle_t*)this; + 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, referer); } - +#endif /* * These are local overrides for various environment variables in Emacs.