1 /* native/vm/Method.c - java/lang/reflect/Method
3 Copyright (C) 1996-2005 R. Grafl, A. Krall, C. Kruegel, C. Oates,
4 R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner,
5 C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger,
6 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., 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 1735 2004-12-07 14:33:27Z twisti $
37 #include "native/jni.h"
38 #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_reflect_Method.h"
42 #include "toolbox/logging.h"
46 * Class: java_lang_reflect_Method
47 * Method: getModifiers
50 JNIEXPORT s4 JNICALL Java_java_lang_reflect_Method_getModifiers(JNIEnv *env, java_lang_reflect_Method *this)
52 classinfo *c = (classinfo *) this->declaringClass;
54 if (this->slot < 0 || this->slot >= c->methodscount)
55 panic("error illegal slot for method in class (getReturnType)");
57 return (c->methods[this->slot]).flags &
58 (ACC_PUBLIC | ACC_PRIVATE | ACC_PROTECTED | ACC_ABSTRACT | ACC_STATIC | ACC_FINAL |
59 ACC_SYNCHRONIZED | ACC_NATIVE | ACC_STRICT);
64 * Class: java_lang_reflect_Method
65 * Method: getReturnType
66 * Signature: ()Ljava/lang/Class;
68 JNIEXPORT java_lang_Class* JNICALL Java_java_lang_reflect_Method_getReturnType(JNIEnv *env, java_lang_reflect_Method *this)
70 classinfo *c = (classinfo *) this->declaringClass;
72 if (this->slot < 0 || this->slot >= c->methodscount)
73 panic("error illegal slot for method in class (getReturnType)");
75 return (java_lang_Class *) get_returntype(&(c->methods[this->slot]));
80 * Class: java_lang_reflect_Method
81 * Method: getParameterTypes
82 * Signature: ()[Ljava/lang/Class;
84 JNIEXPORT java_objectarray* JNICALL Java_java_lang_reflect_Method_getParameterTypes(JNIEnv *env, java_lang_reflect_Method *this)
86 classinfo *c = (classinfo *) this->declaringClass;
88 if (this->slot < 0 || this->slot >= c->methodscount)
89 panic("error illegal slot for method in class(getParameterTypes)");
91 return get_parametertypes(&(c->methods[this->slot]));
96 * Class: java_lang_reflect_Method
97 * Method: getExceptionTypes
98 * Signature: ()[Ljava/lang/Class;
100 JNIEXPORT java_objectarray* JNICALL Java_java_lang_reflect_Method_getExceptionTypes(JNIEnv *env, java_lang_reflect_Method *this)
102 classinfo *c = (classinfo *) this->declaringClass;
104 if (this->slot < 0 || this->slot >= c->methodscount)
105 panic("error illegal slot for method in class(getExceptionTypes)");
107 return get_exceptiontypes(&(c->methods[this->slot]));
113 * Class: java_lang_reflect_Method
114 * Method: invokeNative
115 * Signature: (Ljava/lang/Object;[Ljava/lang/Object;Ljava/lang/Class;I)Ljava/lang/Object;
117 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)
119 struct methodinfo *mi;
121 classinfo *c = (classinfo *) declaringClass;
122 if (slot < 0 || slot >= c->methodscount) {
123 panic("error illegal slot for method in class(getParameterTypes)");
126 mi = &(c->methods[slot]);
128 return (java_lang_Object *) jni_method_invokeNativeHelper(env, mi, (jobject) obj, params);
133 * These are local overrides for various environment variables in Emacs.
134 * Please do not remove this and leave it at the end of the file, where
135 * Emacs will automagically detect them.
136 * ---------------------------------------------------------------------
139 * indent-tabs-mode: t