1 /* src/native/vm/gnu/java_lang_reflect_Method.c
3 Copyright (C) 1996-2005, 2006, 2007 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 $Id: java_lang_reflect_Method.c 7719 2007-04-16 15:29:29Z twisti $
36 #include "native/jni.h"
37 #include "native/native.h"
38 #include "native/include/java_lang_Object.h"
39 #include "native/include/java_lang_Class.h"
40 #include "native/include/java_lang_String.h"
41 #include "native/include/java_lang_reflect_Method.h"
43 #include "vm/access.h"
44 #include "vm/global.h"
45 #include "vm/builtin.h"
46 #include "vm/exceptions.h"
47 #include "vm/initialize.h"
48 #include "vm/resolve.h"
49 #include "vm/stringlocal.h"
53 * Class: java/lang/reflect/Method
54 * Method: getModifiersInternal
57 JNIEXPORT s4 JNICALL Java_java_lang_reflect_Method_getModifiersInternal(JNIEnv *env, java_lang_reflect_Method *this)
62 c = (classinfo *) this->declaringClass;
63 m = &(c->methods[this->slot]);
70 * Class: java/lang/reflect/Method
71 * Method: getReturnType
72 * Signature: ()Ljava/lang/Class;
74 JNIEXPORT java_lang_Class* JNICALL Java_java_lang_reflect_Method_getReturnType(JNIEnv *env, java_lang_reflect_Method *this)
80 c = (classinfo *) this->declaringClass;
81 m = &(c->methods[this->slot]);
83 td = &(m->parseddesc->returntype);
85 if (!resolve_class_from_typedesc(td, true, false, &c))
88 return (java_lang_Class *) c;
93 * Class: java/lang/reflect/Method
94 * Method: getParameterTypes
95 * Signature: ()[Ljava/lang/Class;
97 JNIEXPORT java_objectarray* JNICALL Java_java_lang_reflect_Method_getParameterTypes(JNIEnv *env, java_lang_reflect_Method *this)
102 c = (classinfo *) this->declaringClass;
103 m = &(c->methods[this->slot]);
105 return method_get_parametertypearray(m);
110 * Class: java/lang/reflect/Method
111 * Method: getExceptionTypes
112 * Signature: ()[Ljava/lang/Class;
114 JNIEXPORT java_objectarray* JNICALL Java_java_lang_reflect_Method_getExceptionTypes(JNIEnv *env, java_lang_reflect_Method *this)
119 c = (classinfo *) this->declaringClass;
120 m = &(c->methods[this->slot]);
122 return method_get_exceptionarray(m);
127 * Class: java/lang/reflect/Method
128 * Method: invokeNative
129 * Signature: (Ljava/lang/Object;[Ljava/lang/Object;Ljava/lang/Class;I)Ljava/lang/Object;
131 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)
136 c = (classinfo *) declaringClass;
137 m = &(c->methods[slot]);
139 /* check method access */
141 /* check if we should bypass security checks (AccessibleObject) */
143 if (this->flag == false) {
144 if (!access_check_member(c, m->flags, 1))
148 /* check if method class is initialized */
150 if (!(c->state & CLASS_INITIALIZED))
151 if (!initialize_class(c))
154 /* call the Java method via a helper function */
156 return (java_lang_Object *) _Jv_jni_invokeNative(m, (jobject) o, args);
161 * Class: java/lang/reflect/Method
162 * Method: getSignature
163 * Signature: ()Ljava/lang/String;
165 JNIEXPORT java_lang_String* JNICALL Java_java_lang_reflect_Method_getSignature(JNIEnv *env, java_lang_reflect_Method* this)
169 java_objectheader *o;
171 c = (classinfo *) this->declaringClass;
172 m = &(c->methods[this->slot]);
174 if (m->signature == NULL)
177 o = javastring_new(m->signature);
179 /* in error case o is NULL */
181 return (java_lang_String *) o;
186 * These are local overrides for various environment variables in Emacs.
187 * Please do not remove this and leave it at the end of the file, where
188 * Emacs will automagically detect them.
189 * ---------------------------------------------------------------------
192 * indent-tabs-mode: t