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 8123 2007-06-20 23:50:55Z michi $
36 #include "native/jni.h"
37 #include "native/native.h"
39 #include "native/include/java_lang_Object.h"
40 #include "native/include/java_lang_Class.h"
41 #include "native/include/java_lang_String.h"
43 #include "native/include/java_lang_reflect_Method.h"
45 #include "native/vm/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/resolve.h"
53 #include "vm/stringlocal.h"
55 #include "vmcore/method.h"
58 /* native methods implemented by this file ************************************/
60 static JNINativeMethod methods[] = {
61 { "getModifiersInternal", "()I", (void *) (ptrint) &Java_java_lang_reflect_Method_getModifiersInternal },
62 { "getReturnType", "()Ljava/lang/Class;", (void *) (ptrint) &Java_java_lang_reflect_Method_getReturnType },
63 { "getParameterTypes", "()[Ljava/lang/Class;", (void *) (ptrint) &Java_java_lang_reflect_Method_getParameterTypes },
64 { "getExceptionTypes", "()[Ljava/lang/Class;", (void *) (ptrint) &Java_java_lang_reflect_Method_getExceptionTypes },
65 { "invokeNative", "(Ljava/lang/Object;[Ljava/lang/Object;Ljava/lang/Class;I)Ljava/lang/Object;", (void *) (ptrint) &Java_java_lang_reflect_Method_invokeNative },
66 { "getSignature", "()Ljava/lang/String;", (void *) (ptrint) &Java_java_lang_reflect_Method_getSignature },
70 /* _Jv_java_lang_reflect_Method_init *******************************************
72 Register native functions.
74 *******************************************************************************/
76 void _Jv_java_lang_reflect_Method_init(void)
80 u = utf_new_char("java/lang/reflect/Method");
82 native_method_register(u, methods, NATIVE_METHODS_COUNT);
87 * Class: java/lang/reflect/Method
88 * Method: getModifiersInternal
91 JNIEXPORT s4 JNICALL Java_java_lang_reflect_Method_getModifiersInternal(JNIEnv *env, java_lang_reflect_Method *this)
96 c = (classinfo *) this->declaringClass;
97 m = &(c->methods[this->slot]);
104 * Class: java/lang/reflect/Method
105 * Method: getReturnType
106 * Signature: ()Ljava/lang/Class;
108 JNIEXPORT java_lang_Class* JNICALL Java_java_lang_reflect_Method_getReturnType(JNIEnv *env, java_lang_reflect_Method *this)
114 c = (classinfo *) this->declaringClass;
115 m = &(c->methods[this->slot]);
117 result = method_returntype_get(m);
119 return (java_lang_Class *) result;
124 * Class: java/lang/reflect/Method
125 * Method: getParameterTypes
126 * Signature: ()[Ljava/lang/Class;
128 JNIEXPORT java_objectarray* JNICALL Java_java_lang_reflect_Method_getParameterTypes(JNIEnv *env, java_lang_reflect_Method *this)
133 c = (classinfo *) this->declaringClass;
134 m = &(c->methods[this->slot]);
136 return method_get_parametertypearray(m);
141 * Class: java/lang/reflect/Method
142 * Method: getExceptionTypes
143 * Signature: ()[Ljava/lang/Class;
145 JNIEXPORT java_objectarray* JNICALL Java_java_lang_reflect_Method_getExceptionTypes(JNIEnv *env, java_lang_reflect_Method *this)
150 c = (classinfo *) this->declaringClass;
151 m = &(c->methods[this->slot]);
153 return method_get_exceptionarray(m);
158 * Class: java/lang/reflect/Method
159 * Method: invokeNative
160 * Signature: (Ljava/lang/Object;[Ljava/lang/Object;Ljava/lang/Class;I)Ljava/lang/Object;
162 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)
164 /* just to be sure */
166 assert(this->declaringClass == declaringClass);
167 assert(this->slot == slot);
169 return _Jv_java_lang_reflect_Method_invoke(this, o, args);
174 * Class: java/lang/reflect/Method
175 * Method: getSignature
176 * Signature: ()Ljava/lang/String;
178 JNIEXPORT java_lang_String* JNICALL Java_java_lang_reflect_Method_getSignature(JNIEnv *env, java_lang_reflect_Method* this)
182 java_objectheader *o;
184 c = (classinfo *) this->declaringClass;
185 m = &(c->methods[this->slot]);
187 if (m->signature == NULL)
190 o = javastring_new(m->signature);
192 /* in error case o is NULL */
194 return (java_lang_String *) o;
199 * These are local overrides for various environment variables in Emacs.
200 * Please do not remove this and leave it at the end of the file, where
201 * Emacs will automagically detect them.
202 * ---------------------------------------------------------------------
205 * indent-tabs-mode: t