1 /* src/native/vm/java_lang_reflect_Method.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
34 #include "native/jni.h"
35 #include "native/llni.h"
36 #include "native/native.h"
38 #include "native/include/java_lang_Object.h"
40 #include "native/include/java_lang_reflect_Method.h"
42 #include "vm/access.h"
43 #include "vm/builtin.h"
44 #include "vm/initialize.h"
46 #include "vmcore/class.h"
47 #include "vmcore/method.h"
51 * Class: java/lang/reflect/Method
53 * Signature: (Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;
55 java_lang_Object *_Jv_java_lang_reflect_Method_invoke(java_lang_reflect_Method *this, java_lang_Object *o, java_handle_objectarray_t *args)
62 LLNI_field_get_cls(this, clazz, c);
63 LLNI_field_get_val(this, slot , slot);
64 m = &(c->methods[slot]);
67 /* check method access */
69 /* check if we should bypass security checks (AccessibleObject) */
71 #if defined(WITH_CLASSPATH_GNU)
72 LLNI_field_get_val(this, flag, override);
73 #elif defined(WITH_CLASSPATH_SUN)
74 LLNI_field_get_val(this, override, override);
76 # error unknown classpath configuration
79 if (override == false) {
80 #if defined(WITH_CLASSPATH_GNU)
81 /* This method is always called like this:
82 [0] java.lang.reflect.Method.invokeNative (Native Method)
83 [1] java.lang.reflect.Method.invoke (Method.java:329)
87 if (!access_check_method(m, 2))
89 #elif defined(WITH_CLASSPATH_SUN)
90 /* We only pass 1 here as stacktrace_get_caller_class, which
91 is called from access_check_method, skips
92 java.lang.reflect.Method.invoke(). */
94 if (!access_check_method(m, 1))
99 /* check if method class is initialized */
101 if (!(c->state & CLASS_INITIALIZED))
102 if (!initialize_class(c))
105 /* call the Java method via a helper function */
107 return (java_lang_Object *) _Jv_jni_invokeNative(m, (java_handle_t *) o, args);
112 * These are local overrides for various environment variables in Emacs.
113 * Please do not remove this and leave it at the end of the file, where
114 * Emacs will automagically detect them.
115 * ---------------------------------------------------------------------
118 * indent-tabs-mode: t