1 /* src/native/vm/Method.c - java/lang/reflect/Method
3 Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
4 C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
5 E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
6 J. Wenninger, Institut f. Computersprachen - TU Wien
8 This file is part of CACAO.
10 This program is free software; you can redistribute it and/or
11 modify it under the terms of the GNU General Public License as
12 published by the Free Software Foundation; either version 2, or (at
13 your option) any later version.
15 This program is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
25 Contact: cacao@cacaojvm.org
27 Authors: Roman Obermaiser
29 Changes: Joseph Wenninger
32 $Id: java_lang_reflect_Method.c 5223 2006-08-08 16:21:22Z edwin $
43 #include "native/jni.h"
44 #include "native/native.h"
45 #include "native/include/java_lang_Object.h"
46 #include "native/include/java_lang_Class.h"
47 #include "native/include/java_lang_reflect_Method.h"
48 #include "vm/access.h"
49 #include "vm/global.h"
50 #include "vm/builtin.h"
51 #include "vm/exceptions.h"
52 #include "vm/initialize.h"
53 #include "vm/stringlocal.h"
57 * Class: java/lang/reflect/Method
58 * Method: getModifiersInternal
61 JNIEXPORT s4 JNICALL Java_java_lang_reflect_Method_getModifiersInternal(JNIEnv *env, java_lang_reflect_Method *this)
66 c = (classinfo *) this->declaringClass;
67 m = &(c->methods[this->slot]);
74 * Class: java/lang/reflect/Method
75 * Method: getReturnType
76 * Signature: ()Ljava/lang/Class;
78 JNIEXPORT java_lang_Class* JNICALL Java_java_lang_reflect_Method_getReturnType(JNIEnv *env, java_lang_reflect_Method *this)
83 c = (classinfo *) this->declaringClass;
84 m = &(c->methods[this->slot]);
86 return (java_lang_Class *) native_get_returntype(m);
91 * Class: java/lang/reflect/Method
92 * Method: getParameterTypes
93 * Signature: ()[Ljava/lang/Class;
95 JNIEXPORT java_objectarray* JNICALL Java_java_lang_reflect_Method_getParameterTypes(JNIEnv *env, java_lang_reflect_Method *this)
100 c = (classinfo *) this->declaringClass;
101 m = &(c->methods[this->slot]);
103 return native_get_parametertypes(m);
108 * Class: java/lang/reflect/Method
109 * Method: getExceptionTypes
110 * Signature: ()[Ljava/lang/Class;
112 JNIEXPORT java_objectarray* JNICALL Java_java_lang_reflect_Method_getExceptionTypes(JNIEnv *env, java_lang_reflect_Method *this)
117 c = (classinfo *) this->declaringClass;
118 m = &(c->methods[this->slot]);
120 return native_get_exceptiontypes(m);
125 * Class: java/lang/reflect/Method
126 * Method: invokeNative
127 * Signature: (Ljava/lang/Object;[Ljava/lang/Object;Ljava/lang/Class;I)Ljava/lang/Object;
129 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)
133 java_objectarray *oa;
134 classinfo *callerclass;
136 c = (classinfo *) declaringClass;
137 m = &(c->methods[slot]);
139 /* check method access */
140 /* check if we should bypass security checks (AccessibleObject) */
142 if (this->flag == false) {
143 if (!access_check_caller(c, m->flags, 1))
147 /* check if method class is initialized */
149 if (!(c->state & CLASS_INITIALIZED))
150 if (!initialize_class(c))
153 /* call the Java method via a helper function */
155 return (java_lang_Object *) _Jv_jni_invokeNative(m, (jobject) o, args);
160 * These are local overrides for various environment variables in Emacs.
161 * Please do not remove this and leave it at the end of the file, where
162 * Emacs will automagically detect them.
163 * ---------------------------------------------------------------------
166 * indent-tabs-mode: t