* Removed all Id tags.
[cacao.git] / src / native / vm / java_lang_reflect_Method.c
index 7e639af751cc7477fc9bc4d9ac6409b7ab985e21..b8c9646b206d3e102a2c86efcda407706e047f12 100644 (file)
@@ -1,6 +1,6 @@
-/* src/native/vm/Method.c - java/lang/reflect/Method
+/* src/native/vm/java_lang_reflect_Method.c
 
-   Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
+   Copyright (C) 2007 R. Grafl, A. Krall, C. Kruegel,
    C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
    E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
    J. Wenninger, Institut f. Computersprachen - TU Wien
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   Contact: cacao@cacaojvm.org
-
-   Authors: Roman Obermaiser
-
-   Changes: Joseph Wenninger
-            Christian Thalinger
-
-   $Id: java_lang_reflect_Method.c 5225 2006-08-08 19:23:44Z edwin $
-
 */
 
 
 #include "vm/types.h"
 
 #include "native/jni.h"
+#include "native/llni.h"
 #include "native/native.h"
+
 #include "native/include/java_lang_Object.h"
-#include "native/include/java_lang_Class.h"
+
 #include "native/include/java_lang_reflect_Method.h"
+
 #include "vm/access.h"
-#include "vm/global.h"
 #include "vm/builtin.h"
-#include "vm/exceptions.h"
 #include "vm/initialize.h"
-#include "vm/stringlocal.h"
-
-
-/*
- * Class:     java/lang/reflect/Method
- * Method:    getModifiersInternal
- * Signature: ()I
- */
-JNIEXPORT s4 JNICALL Java_java_lang_reflect_Method_getModifiersInternal(JNIEnv *env, java_lang_reflect_Method *this)
-{
-       classinfo  *c;
-       methodinfo *m;
 
-       c = (classinfo *) this->declaringClass;
-       m = &(c->methods[this->slot]);
-
-       return m->flags;
-}
+#include "vmcore/class.h"
+#include "vmcore/method.h"
 
 
 /*
  * Class:     java/lang/reflect/Method
- * Method:    getReturnType
- * Signature: ()Ljava/lang/Class;
+ * Method:    invoke
+ * Signature: (Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;
  */
-JNIEXPORT java_lang_Class* JNICALL Java_java_lang_reflect_Method_getReturnType(JNIEnv *env, java_lang_reflect_Method *this)
+java_lang_Object *_Jv_java_lang_reflect_Method_invoke(java_lang_reflect_Method *this, java_lang_Object *o, java_handle_objectarray_t *args)
 {
        classinfo  *c;
        methodinfo *m;
+       s4          override;
+       int32_t     slot;
 
-       c = (classinfo *) this->declaringClass;
-       m = &(c->methods[this->slot]);
-
-       return (java_lang_Class *) native_get_returntype(m);
-}
-
-
-/*
- * Class:     java/lang/reflect/Method
- * Method:    getParameterTypes
- * Signature: ()[Ljava/lang/Class;
- */
-JNIEXPORT java_objectarray* JNICALL Java_java_lang_reflect_Method_getParameterTypes(JNIEnv *env, java_lang_reflect_Method *this)
-{
-       classinfo  *c;
-       methodinfo *m;
-
-       c = (classinfo *) this->declaringClass;
-       m = &(c->methods[this->slot]);
-
-       return native_get_parametertypes(m);
-}
-
-
-/*
- * Class:     java/lang/reflect/Method
- * Method:    getExceptionTypes
- * Signature: ()[Ljava/lang/Class;
- */
-JNIEXPORT java_objectarray* JNICALL Java_java_lang_reflect_Method_getExceptionTypes(JNIEnv *env, java_lang_reflect_Method *this)
-{
-       classinfo  *c;
-       methodinfo *m;
-
-       c = (classinfo *) this->declaringClass;
-       m = &(c->methods[this->slot]);
-
-       return native_get_exceptiontypes(m);
-}
-
-
-/*
- * Class:     java/lang/reflect/Method
- * Method:    invokeNative
- * Signature: (Ljava/lang/Object;[Ljava/lang/Object;Ljava/lang/Class;I)Ljava/lang/Object;
- */
-JNIEXPORT java_lang_Object* JNICALL Java_java_lang_reflect_Method_invokeNative(JNIEnv *env, java_lang_reflect_Method *this, java_lang_Object *o, java_objectarray *args, java_lang_Class *declaringClass, s4 slot)
-{
-       classinfo        *c;
-       methodinfo       *m;
-
-       c = (classinfo *) declaringClass;
+       LLNI_field_get_cls(this, clazz, c);
+       LLNI_field_get_val(this, slot , slot);
        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 defined(WITH_CLASSPATH_GNU)
+       LLNI_field_get_val(this, flag, override);
+#elif defined(WITH_CLASSPATH_SUN)
+       LLNI_field_get_val(this, override, override);
+#else
+# error unknown classpath configuration
+#endif
+
+       if (override == false) {
+               if (!access_check_method(m, 1))
                        return NULL;
        }
 
@@ -150,7 +89,7 @@ JNIEXPORT java_lang_Object* JNICALL Java_java_lang_reflect_Method_invokeNative(J
 
        /* call the Java method via a helper function */
 
-       return (java_lang_Object *) _Jv_jni_invokeNative(m, (jobject) o, args);
+       return (java_lang_Object *) _Jv_jni_invokeNative(m, (java_handle_t *) o, args);
 }