CACAO
gnu_classpath_VMStackWalker.cpp
Go to the documentation of this file.
1 /* src/native/vm/gnuclasspath/gnu_classpath_VMStackWalker.cpp
2 
3  Copyright (C) 1996-2013
4  CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
5 
6  This file is part of CACAO.
7 
8  This program is free software; you can redistribute it and/or
9  modify it under the terms of the GNU General Public License as
10  published by the Free Software Foundation; either version 2, or (at
11  your option) any later version.
12 
13  This program is distributed in the hope that it will be useful, but
14  WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with this program; if not, write to the Free Software
20  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21  02110-1301, USA.
22 
23 */
24 
25 
26 #include "config.h"
27 
28 #include <stdint.h>
29 
30 #include "native/jni.hpp"
31 #include "native/native.hpp"
32 
33 #if defined(ENABLE_JNI_HEADERS)
34 # include "native/vm/include/gnu_classpath_VMStackWalker.h"
35 #endif
36 
37 #include "vm/class.hpp"
38 #include "vm/global.hpp"
39 #include "vm/utf8.hpp"
40 #include "vm/vm.hpp"
41 
42 #include "vm/jit/stacktrace.hpp"
43 
44 
45 // Native functions are exported as C functions.
46 extern "C" {
47 
48 /*
49  * Class: gnu/classpath/VMStackWalker
50  * Method: getClassContext
51  * Signature: ()[Ljava/lang/Class;
52  */
54 {
56 
58 
59  return (jobjectArray) oa;
60 }
61 
62 
63 /*
64  * Class: gnu/classpath/VMStackWalker
65  * Method: getCallingClass
66  * Signature: ()Ljava/lang/Class;
67  */
69 {
70  classinfo *c;
71 
73 
74  return (jclass) c;
75 }
76 
77 
78 /*
79  * Class: gnu/classpath/VMStackWalker
80  * Method: getCallingClassLoader
81  * Signature: ()Ljava/lang/ClassLoader;
82  */
84 {
85  classinfo *c;
86  classloader_t *cl;
87 
89  cl = class_get_classloader(c);
90 
91  return (jobject) cl;
92 }
93 
94 
95 /*
96  * Class: gnu/classpath/VMStackWalker
97  * Method: firstNonNullClassLoader
98  * Signature: ()Ljava/lang/ClassLoader;
99  */
101 {
102  classloader_t *cl;
103 
105 
106  return (jobject) cl;
107 }
108 
109 } // extern "C"
110 
111 
112 /* native methods implemented by this file ************************************/
113 
114 static JNINativeMethod methods[] = {
115  { (char*) "getClassContext", (char*) "()[Ljava/lang/Class;", (void*) (uintptr_t) &Java_gnu_classpath_VMStackWalker_getClassContext },
116  { (char*) "getCallingClass", (char*) "()Ljava/lang/Class;", (void*) (uintptr_t) &Java_gnu_classpath_VMStackWalker_getCallingClass },
117  { (char*) "getCallingClassLoader", (char*) "()Ljava/lang/ClassLoader;", (void*) (uintptr_t) &Java_gnu_classpath_VMStackWalker_getCallingClassLoader },
118  { (char*) "firstNonNullClassLoader", (char*) "()Ljava/lang/ClassLoader;", (void*) (uintptr_t) &Java_gnu_classpath_VMStackWalker_firstNonNullClassLoader },
119 };
120 
121 
122 /* _Jv_gnu_classpath_VMStackWalker_init ****************************************
123 
124  Register native functions.
125 
126 *******************************************************************************/
127 
129 {
130  Utf8String u = Utf8String::from_utf8("gnu/classpath/VMStackWalker");
131 
134 }
135 
136 
137 /*
138  * These are local overrides for various environment variables in Emacs.
139  * Please do not remove this and leave it at the end of the file, where
140  * Emacs will automagically detect them.
141  * ---------------------------------------------------------------------
142  * Local variables:
143  * mode: c++
144  * indent-tabs-mode: t
145  * c-basic-offset: 4
146  * tab-width: 4
147  * End:
148  * vim:noexpandtab:sw=4:ts=4:
149  */
classinfo * stacktrace_get_caller_class(int depth)
Definition: stacktrace.cpp:784
Table containing all native methods registered with the VM.
Definition: native.hpp:132
NativeMethods & get_nativemethods()
Definition: vm.hpp:128
void register_methods(Utf8String classname, const JNINativeMethod *methods, size_t count)
Register native methods with the VM.
Definition: native.cpp:242
_Jv_JNIEnv JNIEnv
Definition: jni.hpp:112
classloader_t * stacktrace_first_nonnull_classloader(void)
Returns the first non-null (user-defined) classloader on the stack.
Definition: stacktrace.cpp:851
JNIEXPORT jclass JNICALL Java_gnu_classpath_VMStackWalker_getCallingClass(JNIEnv *env, jclass clazz)
#define NATIVE_METHODS_COUNT
Definition: native.hpp:45
void _Jv_gnu_classpath_VMStackWalker_init(void)
static classloader_t * class_get_classloader(classinfo *c)
Definition: class.hpp:402
java_handle_objectarray_t * stacktrace_getClassContext(void)
Definition: stacktrace.cpp:978
static Utf8String from_utf8(const char *, size_t)
Definition: utf8.cpp:335
static JNINativeMethod methods[]
JNIEXPORT jobject JNICALL Java_gnu_classpath_VMStackWalker_firstNonNullClassLoader(JNIEnv *env, jclass clazz)
JNIEXPORT jobject JNICALL Java_gnu_classpath_VMStackWalker_getCallingClassLoader(JNIEnv *env, jclass clazz)
JNIEXPORT jobjectArray JNICALL Java_gnu_classpath_VMStackWalker_getClassContext(JNIEnv *env, jclass clazz)
static VM * get_current()
Definition: vm.hpp:99