1 /* nat/Method.c - java/lang/reflect/Method
3 Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
4 R. Grafl, A. Krall, C. Kruegel, C. Oates, R. Obermaisser,
5 M. Probst, S. Ring, E. Steiner, C. Thalinger, D. Thuernbeck,
6 P. Tomsich, J. Wenninger
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., 59 Temple Place - Suite 330, Boston, MA
25 Contact: cacao@complang.tuwien.ac.at
27 Authors: Roman Obermaiser
29 Changes: Joseph Wenninger
31 $Id: Method.c 1537 2004-11-18 12:12:05Z twisti $
43 #include "toolbox/logging.h"
44 #include "nat/java_lang_Object.h"
45 #include "nat/java_lang_Class.h"
46 #include "nat/java_lang_reflect_Method.h"
50 * Class: java_lang_reflect_Method
51 * Method: getModifiers
54 JNIEXPORT s4 JNICALL Java_java_lang_reflect_Method_getModifiers(JNIEnv *env, java_lang_reflect_Method *this)
56 classinfo *c = (classinfo *) this->declaringClass;
58 if (this->slot < 0 || this->slot >= c->methodscount)
59 panic("error illegal slot for method in class (getReturnType)");
61 return (c->methods[this->slot]).flags &
62 (ACC_PUBLIC | ACC_PRIVATE | ACC_PROTECTED | ACC_ABSTRACT | ACC_STATIC | ACC_FINAL |
63 ACC_SYNCHRONIZED | ACC_NATIVE | ACC_STRICT);
68 * Class: java_lang_reflect_Method
69 * Method: getReturnType
70 * Signature: ()Ljava/lang/Class;
72 JNIEXPORT java_lang_Class* JNICALL Java_java_lang_reflect_Method_getReturnType(JNIEnv *env, java_lang_reflect_Method *this)
74 classinfo *c = (classinfo *) this->declaringClass;
76 if (this->slot < 0 || this->slot >= c->methodscount)
77 panic("error illegal slot for method in class (getReturnType)");
79 return (java_lang_Class *) get_returntype(&(c->methods[this->slot]));
84 * Class: java_lang_reflect_Method
85 * Method: getParameterTypes
86 * Signature: ()[Ljava/lang/Class;
88 JNIEXPORT java_objectarray* JNICALL Java_java_lang_reflect_Method_getParameterTypes(JNIEnv *env, java_lang_reflect_Method *this)
90 classinfo *c = (classinfo *) this->declaringClass;
92 if (this->slot < 0 || this->slot >= c->methodscount)
93 panic("error illegal slot for method in class(getParameterTypes)");
95 return get_parametertypes(&(c->methods[this->slot]));
100 * Class: java_lang_reflect_Method
101 * Method: getExceptionTypes
102 * Signature: ()[Ljava/lang/Class;
104 JNIEXPORT java_objectarray* JNICALL Java_java_lang_reflect_Method_getExceptionTypes(JNIEnv *env, java_lang_reflect_Method *this)
106 classinfo *c = (classinfo *) this->declaringClass;
108 if (this->slot < 0 || this->slot >= c->methodscount)
109 panic("error illegal slot for method in class(getExceptionTypes)");
111 return get_exceptiontypes(&(c->methods[this->slot]));
117 * Class: java_lang_reflect_Method
118 * Method: invokeNative
119 * Signature: (Ljava/lang/Object;[Ljava/lang/Object;Ljava/lang/Class;I)Ljava/lang/Object;
121 JNIEXPORT java_lang_Object* JNICALL Java_java_lang_reflect_Method_invokeNative(JNIEnv *env, java_lang_reflect_Method *this, java_lang_Object *obj, java_objectarray *params, java_lang_Class *declaringClass, s4 slot)
123 struct methodinfo *mi;
125 classinfo *c = (classinfo *) declaringClass;
126 if (slot < 0 || slot >= c->methodscount) {
127 panic("error illegal slot for method in class(getParameterTypes)");
130 mi = &(c->methods[slot]);
132 return (java_lang_Object *) jni_method_invokeNativeHelper(env, mi, (jobject) obj, params);
137 * These are local overrides for various environment variables in Emacs.
138 * Please do not remove this and leave it at the end of the file, where
139 * Emacs will automagically detect them.
140 * ---------------------------------------------------------------------
143 * indent-tabs-mode: t