1 /* src/native/vm/java_lang_reflect_Constructor.c
3 Copyright (C) 1996-2005, 2006 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 Contact: cacao@cacaojvm.org
27 Authors: Roman Obermaiser
31 $Id: java_lang_reflect_Constructor.c 6168 2006-12-11 00:28:17Z twisti $
43 #include "native/jni.h"
44 #include "native/native.h"
45 #include "native/include/java_lang_Class.h"
46 #include "native/include/java_lang_Object.h"
47 #include "native/include/java_lang_String.h"
48 #include "native/include/java_lang_reflect_Constructor.h"
49 #include "toolbox/logging.h"
51 #include "vm/exceptions.h"
52 #include "vm/method.h"
53 #include "vm/access.h"
54 #include "vm/stringlocal.h"
58 * Class: java/lang/reflect/Constructor
59 * Method: getModifiersInternal
62 JNIEXPORT s4 JNICALL Java_java_lang_reflect_Constructor_getModifiersInternal(JNIEnv *env, java_lang_reflect_Constructor *this)
67 c = (classinfo *) (this->clazz);
68 m = &(c->methods[this->slot]);
75 * Class: java/lang/reflect/Constructor
76 * Method: getParameterTypes
77 * Signature: ()[Ljava/lang/Class;
79 JNIEXPORT java_objectarray* JNICALL Java_java_lang_reflect_Constructor_getParameterTypes(JNIEnv *env, java_lang_reflect_Constructor *this)
84 c = (classinfo *) this->clazz;
85 m = &(c->methods[this->slot]);
87 return native_get_parametertypes(m);
92 * Class: java/lang/reflect/Constructor
93 * Method: getExceptionTypes
94 * Signature: ()[Ljava/lang/Class;
96 JNIEXPORT java_objectarray* JNICALL Java_java_lang_reflect_Constructor_getExceptionTypes(JNIEnv *env, java_lang_reflect_Constructor *this)
101 c = (classinfo *) this->clazz;
102 m = &(c->methods[this->slot]);
104 return native_get_exceptiontypes(m);
109 * Class: java/lang/reflect/Constructor
110 * Method: constructNative
111 * Signature: ([Ljava/lang/Object;)Ljava/lang/Object;
113 JNIEXPORT java_lang_Object* JNICALL Java_java_lang_reflect_Constructor_constructNative(JNIEnv *env, java_lang_reflect_Constructor *this, java_objectarray *args, java_lang_Class *declaringClass, s4 slot)
117 java_objectheader *o;
119 c = (classinfo *) declaringClass;
122 /* find initializer */
125 if (this->parameterTypes->header.size != 0) {
127 new_exception_message(string_java_lang_IllegalArgumentException,
128 "wrong number of arguments");
133 if (this->parameterTypes->header.size != args->header.size) {
135 new_exception_message(string_java_lang_IllegalArgumentException,
136 "wrong number of arguments");
142 if (this->slot >= c->methodscount) {
143 log_text("illegal index in methods table");
147 m = &(c->methods[this->slot]);
149 if (m->name != utf_init) {
150 /* XXX throw an exception here, although this should never happen */
155 /* check method access */
156 /* check if we should bypass security checks (AccessibleObject) */
158 if (this->flag == false) {
159 if (!access_check_caller(c, m->flags, 1))
170 /* call initializer */
172 (void) _Jv_jni_invokeNative(m, o, args);
174 return (java_lang_Object *) o;
179 * Class: java/lang/reflect/Constructor
180 * Method: getSignature
181 * Signature: ()Ljava/lang/String;
183 JNIEXPORT java_lang_String* JNICALL Java_java_lang_reflect_Constructor_getSignature(JNIEnv *env, java_lang_reflect_Constructor *this)
189 c = (classinfo *) this->clazz;
190 m = &(c->methods[this->slot]);
192 if (m->signature == NULL)
195 s = javastring_new(m->signature);
197 /* in error case, s == NULL */
204 * These are local overrides for various environment variables in Emacs.
205 * Please do not remove this and leave it at the end of the file, where
206 * Emacs will automagically detect them.
207 * ---------------------------------------------------------------------
210 * indent-tabs-mode: t