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
31 $Id: java_lang_reflect_Method.c 6213 2006-12-18 17:36:06Z twisti $
42 #include "native/jni.h"
43 #include "native/native.h"
44 #include "native/include/java_lang_Object.h"
45 #include "native/include/java_lang_Class.h"
46 #include "native/include/java_lang_reflect_Method.h"
47 #include "vm/access.h"
48 #include "vm/global.h"
49 #include "vm/builtin.h"
50 #include "vm/exceptions.h"
51 #include "vm/initialize.h"
52 #include "vm/stringlocal.h"
56 * Class: java/lang/reflect/Method
57 * Method: getModifiersInternal
60 JNIEXPORT s4 JNICALL Java_java_lang_reflect_Method_getModifiersInternal(JNIEnv *env, java_lang_reflect_Method *this)
65 c = (classinfo *) this->declaringClass;
66 m = &(c->methods[this->slot]);
73 * Class: java/lang/reflect/Method
74 * Method: getReturnType
75 * Signature: ()Ljava/lang/Class;
77 JNIEXPORT java_lang_Class* JNICALL Java_java_lang_reflect_Method_getReturnType(JNIEnv *env, java_lang_reflect_Method *this)
82 c = (classinfo *) this->declaringClass;
83 m = &(c->methods[this->slot]);
85 return (java_lang_Class *) native_get_returntype(m);
90 * Class: java/lang/reflect/Method
91 * Method: getParameterTypes
92 * Signature: ()[Ljava/lang/Class;
94 JNIEXPORT java_objectarray* JNICALL Java_java_lang_reflect_Method_getParameterTypes(JNIEnv *env, java_lang_reflect_Method *this)
99 c = (classinfo *) this->declaringClass;
100 m = &(c->methods[this->slot]);
102 return native_get_parametertypes(m);
107 * Class: java/lang/reflect/Method
108 * Method: getExceptionTypes
109 * Signature: ()[Ljava/lang/Class;
111 JNIEXPORT java_objectarray* JNICALL Java_java_lang_reflect_Method_getExceptionTypes(JNIEnv *env, java_lang_reflect_Method *this)
116 c = (classinfo *) this->declaringClass;
117 m = &(c->methods[this->slot]);
119 return native_get_exceptiontypes(m);
124 * Class: java/lang/reflect/Method
125 * Method: invokeNative
126 * Signature: (Ljava/lang/Object;[Ljava/lang/Object;Ljava/lang/Class;I)Ljava/lang/Object;
128 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 c = (classinfo *) declaringClass;
134 m = &(c->methods[slot]);
136 /* check method access */
137 /* check if we should bypass security checks (AccessibleObject) */
139 if (this->flag == false) {
140 if (!access_check_caller(c, m->flags, 1))
144 /* check if method class is initialized */
146 if (!(c->state & CLASS_INITIALIZED))
147 if (!initialize_class(c))
150 /* call the Java method via a helper function */
152 return (java_lang_Object *) _Jv_jni_invokeNative(m, (jobject) o, args);
157 * Class: java/lang/reflect/Method
158 * Method: getSignature
159 * Signature: ()Ljava/lang/String;
161 JNIEXPORT java_lang_String* JNICALL Java_java_lang_reflect_Method_getSignature(JNIEnv *env, java_lang_reflect_Method* this)
167 c = (classinfo *) this->declaringClass;
168 m = &(c->methods[this->slot]);
170 if (m->signature == NULL)
173 s = javastring_new(m->signature);
175 /* in error case, s == NULL */
182 * These are local overrides for various environment variables in Emacs.
183 * Please do not remove this and leave it at the end of the file, where
184 * Emacs will automagically detect them.
185 * ---------------------------------------------------------------------
188 * indent-tabs-mode: t