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 7246 2007-01-29 18:49:05Z 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/stringlocal.h"
52 * Class: java/lang/reflect/Method
53 * Method: getModifiersInternal
56 JNIEXPORT s4 JNICALL Java_java_lang_reflect_Method_getModifiersInternal(JNIEnv *env, java_lang_reflect_Method *this)
61 c = (classinfo *) this->declaringClass;
62 m = &(c->methods[this->slot]);
69 * Class: java/lang/reflect/Method
70 * Method: getReturnType
71 * Signature: ()Ljava/lang/Class;
73 JNIEXPORT java_lang_Class* JNICALL Java_java_lang_reflect_Method_getReturnType(JNIEnv *env, java_lang_reflect_Method *this)
78 c = (classinfo *) this->declaringClass;
79 m = &(c->methods[this->slot]);
81 return (java_lang_Class *) native_get_returntype(m);
86 * Class: java/lang/reflect/Method
87 * Method: getParameterTypes
88 * Signature: ()[Ljava/lang/Class;
90 JNIEXPORT java_objectarray* JNICALL Java_java_lang_reflect_Method_getParameterTypes(JNIEnv *env, java_lang_reflect_Method *this)
95 c = (classinfo *) this->declaringClass;
96 m = &(c->methods[this->slot]);
98 return native_get_parametertypes(m);
103 * Class: java/lang/reflect/Method
104 * Method: getExceptionTypes
105 * Signature: ()[Ljava/lang/Class;
107 JNIEXPORT java_objectarray* JNICALL Java_java_lang_reflect_Method_getExceptionTypes(JNIEnv *env, java_lang_reflect_Method *this)
112 c = (classinfo *) this->declaringClass;
113 m = &(c->methods[this->slot]);
115 return native_get_exceptiontypes(m);
120 * Class: java/lang/reflect/Method
121 * Method: invokeNative
122 * Signature: (Ljava/lang/Object;[Ljava/lang/Object;Ljava/lang/Class;I)Ljava/lang/Object;
124 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)
129 c = (classinfo *) declaringClass;
130 m = &(c->methods[slot]);
132 /* check method access */
133 /* check if we should bypass security checks (AccessibleObject) */
135 if (this->flag == false) {
136 if (!access_check_caller(c, m->flags, 1))
140 /* check if method class is initialized */
142 if (!(c->state & CLASS_INITIALIZED))
143 if (!initialize_class(c))
146 /* call the Java method via a helper function */
148 return (java_lang_Object *) _Jv_jni_invokeNative(m, (jobject) o, args);
153 * Class: java/lang/reflect/Method
154 * Method: getSignature
155 * Signature: ()Ljava/lang/String;
157 JNIEXPORT java_lang_String* JNICALL Java_java_lang_reflect_Method_getSignature(JNIEnv *env, java_lang_reflect_Method* this)
163 c = (classinfo *) this->declaringClass;
164 m = &(c->methods[this->slot]);
166 if (m->signature == NULL)
169 s = javastring_new(m->signature);
171 /* in error case, s == NULL */
178 * These are local overrides for various environment variables in Emacs.
179 * Please do not remove this and leave it at the end of the file, where
180 * Emacs will automagically detect them.
181 * ---------------------------------------------------------------------
184 * indent-tabs-mode: t