1 /* src/native/vm/gnu/java_lang_reflect_Constructor.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_Constructor.c 7912 2007-05-18 13:12:09Z twisti $
37 #include "native/jni.h"
38 #include "native/native.h"
40 #include "native/include/java_lang_Class.h"
41 #include "native/include/java_lang_Object.h"
42 #include "native/include/java_lang_String.h"
44 #include "native/include/java_lang_reflect_Constructor.h"
46 #include "toolbox/logging.h"
48 #include "vm/builtin.h"
49 #include "vm/exceptions.h"
50 #include "vm/access.h"
51 #include "vm/stringlocal.h"
53 #include "vmcore/class.h"
54 #include "vmcore/method.h"
57 /* native methods implemented by this file ************************************/
59 static JNINativeMethod methods[] = {
60 { "getModifiersInternal", "()I", (void *) (ptrint) &Java_java_lang_reflect_Constructor_getModifiersInternal },
61 { "getParameterTypes", "()[Ljava/lang/Class;", (void *) (ptrint) &Java_java_lang_reflect_Constructor_getParameterTypes },
62 { "getExceptionTypes", "()[Ljava/lang/Class;", (void *) (ptrint) &Java_java_lang_reflect_Constructor_getExceptionTypes },
63 { "constructNative", "([Ljava/lang/Object;Ljava/lang/Class;I)Ljava/lang/Object;", (void *) (ptrint) &Java_java_lang_reflect_Constructor_constructNative },
64 { "getSignature", "()Ljava/lang/String;", (void *) (ptrint) &Java_java_lang_reflect_Constructor_getSignature },
68 /* _Jv_java_lang_reflect_Constructor_init **************************************
70 Register native functions.
72 *******************************************************************************/
74 void _Jv_java_lang_reflect_Constructor_init(void)
78 u = utf_new_char("java/lang/reflect/Constructor");
80 native_method_register(u, methods, NATIVE_METHODS_COUNT);
85 * Class: java/lang/reflect/Constructor
86 * Method: getModifiersInternal
89 JNIEXPORT s4 JNICALL Java_java_lang_reflect_Constructor_getModifiersInternal(JNIEnv *env, java_lang_reflect_Constructor *this)
94 c = (classinfo *) (this->clazz);
95 m = &(c->methods[this->slot]);
102 * Class: java/lang/reflect/Constructor
103 * Method: getParameterTypes
104 * Signature: ()[Ljava/lang/Class;
106 JNIEXPORT java_objectarray* JNICALL Java_java_lang_reflect_Constructor_getParameterTypes(JNIEnv *env, java_lang_reflect_Constructor *this)
111 c = (classinfo *) this->clazz;
112 m = &(c->methods[this->slot]);
114 return method_get_parametertypearray(m);
119 * Class: java/lang/reflect/Constructor
120 * Method: getExceptionTypes
121 * Signature: ()[Ljava/lang/Class;
123 JNIEXPORT java_objectarray* JNICALL Java_java_lang_reflect_Constructor_getExceptionTypes(JNIEnv *env, java_lang_reflect_Constructor *this)
128 c = (classinfo *) this->clazz;
129 m = &(c->methods[this->slot]);
131 return method_get_exceptionarray(m);
136 * Class: java/lang/reflect/Constructor
137 * Method: constructNative
138 * Signature: ([Ljava/lang/Object;Ljava/lang/Class;I)Ljava/lang/Object;
140 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)
144 java_objectheader *o;
146 c = (classinfo *) declaringClass;
147 m = &(c->methods[this->slot]);
149 /* check method access */
151 /* check if we should bypass security checks (AccessibleObject) */
153 if (this->flag == false) {
154 if (!access_check_member(c, m->flags, 1))
165 /* call initializer */
167 (void) _Jv_jni_invokeNative(m, o, args);
169 return (java_lang_Object *) o;
174 * Class: java/lang/reflect/Constructor
175 * Method: getSignature
176 * Signature: ()Ljava/lang/String;
178 JNIEXPORT java_lang_String* JNICALL Java_java_lang_reflect_Constructor_getSignature(JNIEnv *env, java_lang_reflect_Constructor *this)
182 java_objectheader *o;
184 c = (classinfo *) this->clazz;
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