1 /* src/native/vm/gnuclasspath/gnu_classpath_VMStackWalker.cpp
3 Copyright (C) 1996-2005, 2006, 2007, 2008
4 CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
6 This file is part of CACAO.
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.
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.
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
30 #include "native/jni.hpp"
31 #include "native/native.hpp"
33 #if defined(ENABLE_JNI_HEADERS)
34 # include "native/vm/include/gnu_classpath_VMStackWalker.h"
37 #include "vm/class.hpp"
38 #include "vm/global.h"
41 #include "vm/jit/stacktrace.hpp"
44 // Native functions are exported as C functions.
48 * Class: gnu/classpath/VMStackWalker
49 * Method: getClassContext
50 * Signature: ()[Ljava/lang/Class;
52 JNIEXPORT jobjectArray JNICALL Java_gnu_classpath_VMStackWalker_getClassContext(JNIEnv *env, jclass clazz)
54 java_handle_objectarray_t *oa;
56 oa = stacktrace_getClassContext();
58 return (jobjectArray) oa;
63 * Class: gnu/classpath/VMStackWalker
64 * Method: getCallingClass
65 * Signature: ()Ljava/lang/Class;
67 JNIEXPORT jclass JNICALL Java_gnu_classpath_VMStackWalker_getCallingClass(JNIEnv *env, jclass clazz)
71 c = stacktrace_get_caller_class(2);
78 * Class: gnu/classpath/VMStackWalker
79 * Method: getCallingClassLoader
80 * Signature: ()Ljava/lang/ClassLoader;
82 JNIEXPORT jobject JNICALL Java_gnu_classpath_VMStackWalker_getCallingClassLoader(JNIEnv *env, jclass clazz)
87 c = stacktrace_get_caller_class(2);
88 cl = class_get_classloader(c);
95 * Class: gnu/classpath/VMStackWalker
96 * Method: firstNonNullClassLoader
97 * Signature: ()Ljava/lang/ClassLoader;
99 JNIEXPORT jobject JNICALL Java_gnu_classpath_VMStackWalker_firstNonNullClassLoader(JNIEnv *env, jclass clazz)
103 cl = stacktrace_first_nonnull_classloader();
111 /* native methods implemented by this file ************************************/
113 static JNINativeMethod methods[] = {
114 { (char*) "getClassContext", (char*) "()[Ljava/lang/Class;", (void*) (uintptr_t) &Java_gnu_classpath_VMStackWalker_getClassContext },
115 { (char*) "getCallingClass", (char*) "()Ljava/lang/Class;", (void*) (uintptr_t) &Java_gnu_classpath_VMStackWalker_getCallingClass },
116 { (char*) "getCallingClassLoader", (char*) "()Ljava/lang/ClassLoader;", (void*) (uintptr_t) &Java_gnu_classpath_VMStackWalker_getCallingClassLoader },
117 { (char*) "firstNonNullClassLoader", (char*) "()Ljava/lang/ClassLoader;", (void*) (uintptr_t) &Java_gnu_classpath_VMStackWalker_firstNonNullClassLoader },
121 /* _Jv_gnu_classpath_VMStackWalker_init ****************************************
123 Register native functions.
125 *******************************************************************************/
127 void _Jv_gnu_classpath_VMStackWalker_init(void)
129 utf* u = utf_new_char("gnu/classpath/VMStackWalker");
131 NativeMethods& nm = VM::get_current()->get_nativemethods();
132 nm.register_methods(u, methods, NATIVE_METHODS_COUNT);
137 * These are local overrides for various environment variables in Emacs.
138 * Please do not remove this and leave it at the end of the file, where
139 * Emacs will automagically detect them.
140 * ---------------------------------------------------------------------
143 * indent-tabs-mode: t
147 * vim:noexpandtab:sw=4:ts=4: