1 /* src/native/vm/java_lang_reflect_Constructor.c
3 Copyright (C) 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
35 #include "native/jni.h"
36 #include "native/llni.h"
37 #include "native/native.h"
39 #if defined(WITH_CLASSPATH_SUN)
40 # include "native/include/java_lang_String.h" /* required by j.l.CL */
41 # include "native/include/java_nio_ByteBuffer.h" /* required by j.l.CL */
42 # include "native/include/java_lang_ClassLoader.h" /* required my j.l.C */
45 #include "native/include/java_lang_Object.h" /* required my j.l.C */
46 #include "native/include/java_lang_Class.h"
47 #include "native/include/java_lang_String.h"
49 #include "native/include/java_lang_reflect_Constructor.h"
51 #include "native/vm/java_lang_reflect_Constructor.h"
53 #include "toolbox/logging.h"
55 #include "vm/builtin.h"
56 #include "vm/exceptions.h"
57 #include "vm/access.h"
58 #include "vm/stringlocal.h"
60 #include "vmcore/class.h"
61 #include "vmcore/method.h"
65 * Class: java/lang/reflect/Constructor
66 * Method: getModifiers
69 s4 _Jv_java_lang_reflect_Constructor_getModifiers(JNIEnv *env, java_lang_reflect_Constructor *this)
75 LLNI_field_get_cls(this, clazz, c);
76 LLNI_field_get_val(this, slot , slot);
77 m = &(c->methods[slot]);
84 * Class: java/lang/reflect/Constructor
85 * Method: getParameterTypes
86 * Signature: ()[Ljava/lang/Class;
88 java_handle_objectarray_t *_Jv_java_lang_reflect_Constructor_getParameterTypes(JNIEnv *env, java_lang_reflect_Constructor *this)
94 LLNI_field_get_cls(this, clazz, c);
95 LLNI_field_get_val(this, slot , slot);
96 m = &(c->methods[slot]);
98 return method_get_parametertypearray(m);
103 * Class: java/lang/reflect/Constructor
104 * Method: getExceptionTypes
105 * Signature: ()[Ljava/lang/Class;
107 java_handle_objectarray_t *_Jv_java_lang_reflect_Constructor_getExceptionTypes(JNIEnv *env, java_lang_reflect_Constructor *this)
113 LLNI_field_get_cls(this, clazz, c);
114 LLNI_field_get_val(this, slot , slot);
115 m = &(c->methods[slot]);
117 return method_get_exceptionarray(m);
122 * Class: java/lang/reflect/Constructor
123 * Method: newInstance
124 * Signature: ([Ljava/lang/Object;)Ljava/lang/Object;
126 java_lang_Object *_Jv_java_lang_reflect_Constructor_newInstance(JNIEnv *env, java_lang_reflect_Constructor *this, java_handle_objectarray_t *args)
134 LLNI_field_get_cls(this, clazz, c);
135 LLNI_field_get_val(this, slot , slot);
136 m = &(c->methods[slot]);
138 /* check method access */
140 /* check if we should bypass security checks (AccessibleObject) */
142 #if defined(WITH_CLASSPATH_GNU)
143 LLNI_field_get_val(this, flag, override);
144 #elif defined(WITH_CLASSPATH_SUN)
145 LLNI_field_get_val(this, override, override);
147 # error unknown classpath configuration
150 if (override == false) {
151 if (!access_check_method(m, 1))
162 /* call initializer */
164 (void) _Jv_jni_invokeNative(m, o, args);
166 return (java_lang_Object *) o;
171 * Class: java/lang/reflect/Constructor
172 * Method: getSignature
173 * Signature: ()Ljava/lang/String;
175 java_lang_String *_Jv_java_lang_reflect_Constructor_getSignature(JNIEnv *env, java_lang_reflect_Constructor *this)
182 LLNI_field_get_cls(this, clazz, c);
183 LLNI_field_get_val(this, slot , slot);
184 m = &(c->methods[slot]);
186 if (m->signature == NULL)
189 o = javastring_new(m->signature);
191 /* in error case o is NULL */
193 return (java_lang_String *) o;
198 * These are local overrides for various environment variables in Emacs.
199 * Please do not remove this and leave it at the end of the file, where
200 * Emacs will automagically detect them.
201 * ---------------------------------------------------------------------
204 * indent-tabs-mode: t