Merged revisions 7940-8026 via svnmerge from
[cacao.git] / src / native / vm / gnu / java_lang_reflect_Constructor.c
index f13cde7e5d6da5eb8384dace83899e99988ce233..962e960331a07fdb1324b8e28c4adf385b8b66a6 100644 (file)
@@ -22,7 +22,7 @@
    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 $
+   $Id: java_lang_reflect_Constructor.c 8026 2007-06-07 09:04:51Z twisti $
 
 */
 
 
 #include "native/jni.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"
+#include "native/vm/java_lang_reflect_Constructor.h"
 
-#include "vm/builtin.h"
-#include "vm/exceptions.h"
-#include "vm/access.h"
-#include "vm/stringlocal.h"
+#include "vmcore/utf8.h"
 
-#include "vmcore/class.h"
-#include "vmcore/method.h"
 
+/* native methods implemented by this file ************************************/
 
-/*
- * 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;
+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      },
+};
 
-       c = (classinfo *) (this->clazz);
-       m = &(c->methods[this->slot]);
 
-       return m->flags;
-}
+/* _Jv_java_lang_reflect_Constructor_init **************************************
 
+   Register native functions.
 
-/*
- * 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)
-{
-       classinfo  *c;
-       methodinfo *m;
+*******************************************************************************/
 
-       c = (classinfo *) this->clazz;
-       m = &(c->methods[this->slot]);
-
-       return method_get_parametertypearray(m);
-}
-
-
-/*
- * Class:     java/lang/reflect/Constructor
- * Method:    getExceptionTypes
- * Signature: ()[Ljava/lang/Class;
- */
-JNIEXPORT java_objectarray* JNICALL Java_java_lang_reflect_Constructor_getExceptionTypes(JNIEnv *env, java_lang_reflect_Constructor *this)
+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_exceptionarray(m);
+       native_method_register(u, methods, NATIVE_METHODS_COUNT);
 }
 
 
 /*
  * Class:     java/lang/reflect/Constructor
  * Method:    constructNative
- * Signature: ([Ljava/lang/Object;)Ljava/lang/Object;
+ * 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)
 {
-       classinfo         *c;
-       methodinfo        *m;
-       java_objectheader *o;
-
-       c = (classinfo *) declaringClass;
-       m = &(c->methods[this->slot]);
-
-       /* check method access */
-
-       /* check if we should bypass security checks (AccessibleObject) */
-
-       if (this->flag == false) {
-               if (!access_check_member(c, m->flags, 1))
-                       return NULL;
-       }
-
-       /* 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;
-}
-
-
-/*
- * Class:     java/lang/reflect/Constructor
- * Method:    getSignature
- * Signature: ()Ljava/lang/String;
- */
-JNIEXPORT java_lang_String* JNICALL Java_java_lang_reflect_Constructor_getSignature(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;
+       return _Jv_java_lang_reflect_Constructor_newInstance(env, this, args);
 }