1 /* src/native/vm/Constructor.c - java/lang/reflect/Constructor
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
29 Changes: Joseph Wenninger
32 $Id: Constructor.c 4357 2006-01-22 23:33:38Z twisti $
44 #include "native/jni.h"
45 #include "native/native.h"
46 #include "native/include/java_lang_Class.h"
47 #include "native/include/java_lang_Object.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/stringlocal.h"
57 * Class: java/lang/reflect/Constructor
59 * Signature: ([Ljava/lang/Object;)Ljava/lang/Object;
61 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)
67 c = (classinfo *) declaringClass;
70 /* find initializer */
73 if (this->parameterTypes->header.size != 0) {
75 new_exception_message(string_java_lang_IllegalArgumentException,
76 "wrong number of arguments");
81 if (this->parameterTypes->header.size != args->header.size) {
83 new_exception_message(string_java_lang_IllegalArgumentException,
84 "wrong number of arguments");
90 if (this->slot >= c->methodscount) {
91 log_text("illegal index in methods table");
102 m = &(c->methods[this->slot]);
104 if (m->name != utf_init) {
105 /* XXX throw an exception here, although this should never happen */
110 /* call initializer */
112 (void) _Jv_jni_invokeNative(m, o, args);
114 return (java_lang_Object *) o;
119 * Class: java/lang/reflect/Constructor
120 * Method: getModifiers
123 JNIEXPORT s4 JNICALL Java_java_lang_reflect_Constructor_getModifiers(JNIEnv *env, java_lang_reflect_Constructor *this)
128 c = (classinfo *) (this->clazz);
130 if ((this->slot < 0) || (this->slot >= c->methodscount)) {
131 log_text("error illegal slot for constructor in class");
135 m = &(c->methods[this->slot]);
137 return (m->flags & (ACC_PUBLIC | ACC_PRIVATE | ACC_PROTECTED));
142 * Class: java/lang/reflect/Constructor
143 * Method: getParameterTypes
144 * Signature: ()[Ljava/lang/Class;
146 JNIEXPORT java_objectarray* JNICALL Java_java_lang_reflect_Constructor_getParameterTypes(JNIEnv *env, java_lang_reflect_Constructor *this)
151 c = (classinfo *) this->clazz;
153 if ((this->slot < 0) || (this->slot >= c->methodscount)) {
154 log_text("error illegal slot for constructor in class");
158 m = &(c->methods[this->slot]);
160 return native_get_parametertypes(m);
165 * Class: java/lang/reflect/Constructor
166 * Method: getExceptionTypes
167 * Signature: ()[Ljava/lang/Class;
169 JNIEXPORT java_objectarray* JNICALL Java_java_lang_reflect_Constructor_getExceptionTypes(JNIEnv *env, java_lang_reflect_Constructor *this)
174 c = (classinfo *) this->clazz;
176 if ((this->slot < 0) || (this->slot >= c->methodscount)) {
177 log_text("error illegal slot for constructor in class");
181 m = &(c->methods[this->slot]);
183 return native_get_exceptiontypes(m);
188 * These are local overrides for various environment variables in Emacs.
189 * Please do not remove this and leave it at the end of the file, where
190 * Emacs will automagically detect them.
191 * ---------------------------------------------------------------------
194 * indent-tabs-mode: t