Merged revisions 7797-7917 via svnmerge from
[cacao.git] / src / native / vm / gnu / java_lang_reflect_Method.c
index fd1fed7044d0668c79a898ef21607646dcb46761..f67512682ca7b92e492db87a7d7d9a1dcb668134 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: java_lang_reflect_Method.c 7356 2007-02-14 11:00:28Z twisti $
+   $Id: java_lang_reflect_Method.c 7910 2007-05-16 08:02:52Z twisti $
 
 */
 
 
 #include "native/jni.h"
 #include "native/native.h"
+
 #include "native/include/java_lang_Object.h"
 #include "native/include/java_lang_Class.h"
 #include "native/include/java_lang_String.h"
+
 #include "native/include/java_lang_reflect_Method.h"
 
 #include "vm/access.h"
 #include "vm/builtin.h"
 #include "vm/exceptions.h"
 #include "vm/initialize.h"
+#include "vm/resolve.h"
 #include "vm/stringlocal.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         },
+};
+
+
+/* _Jv_java_lang_reflect_Method_init *******************************************
+
+   Register native functions.
+
+*******************************************************************************/
+
+void _Jv_java_lang_reflect_Method_init(void)
+{
+       utf *u;
+
+       u = utf_new_char("java/lang/reflect/Method");
+
+       native_method_register(u, methods, NATIVE_METHODS_COUNT);
+}
+
+
 /*
  * Class:     java/lang/reflect/Method
  * Method:    getModifiersInternal
@@ -101,7 +132,7 @@ JNIEXPORT java_objectarray* JNICALL Java_java_lang_reflect_Method_getParameterTy
        c = (classinfo *) this->declaringClass;
        m = &(c->methods[this->slot]);
 
-       return native_get_parametertypes(m);
+       return method_get_parametertypearray(m);
 }
 
 
@@ -118,7 +149,7 @@ JNIEXPORT java_objectarray* JNICALL Java_java_lang_reflect_Method_getExceptionTy
        c = (classinfo *) this->declaringClass;
        m = &(c->methods[this->slot]);
 
-       return native_get_exceptiontypes(m);
+       return method_get_exceptionarray(m);
 }
 
 
@@ -136,10 +167,11 @@ JNIEXPORT java_lang_Object* JNICALL Java_java_lang_reflect_Method_invokeNative(J
        m = &(c->methods[slot]);
 
        /* check method access */
+
        /* check if we should bypass security checks (AccessibleObject) */
 
        if (this->flag == false) {
-               if (!access_check_caller(c, m->flags, 1))
+               if (!access_check_member(c, m->flags, 1))
                        return NULL;
        }
 
@@ -162,9 +194,9 @@ JNIEXPORT java_lang_Object* JNICALL Java_java_lang_reflect_Method_invokeNative(J
  */
 JNIEXPORT java_lang_String* JNICALL Java_java_lang_reflect_Method_getSignature(JNIEnv *env, java_lang_reflect_Method* this)
 {
-       classinfo        *c;
-       methodinfo       *m;
-       java_lang_String *s;
+       classinfo         *c;
+       methodinfo        *m;
+       java_objectheader *o;
 
        c = (classinfo *) this->declaringClass;
        m = &(c->methods[this->slot]);
@@ -172,11 +204,11 @@ JNIEXPORT java_lang_String* JNICALL Java_java_lang_reflect_Method_getSignature(J
        if (m->signature == NULL)
                return NULL;
 
-       s = javastring_new(m->signature);
+       o = javastring_new(m->signature);
 
-       /* in error case, s == NULL */
+       /* in error case o is NULL */
 
-       return s;
+       return (java_lang_String *) o;
 }