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.h"
31 #include "native/native.h"
33 #if defined(ENABLE_JNI_HEADERS)
34 # include "native/vm/include/gnu_classpath_VMStackWalker.h"
37 #include "vm/global.h"
39 #include "vm/jit/stacktrace.hpp"
41 #include "vmcore/class.h"
42 #include "vmcore/utf8.h"
45 // Native functions are exported as C functions.
49 * Class: gnu/classpath/VMStackWalker
50 * Method: getClassContext
51 * Signature: ()[Ljava/lang/Class;
53 JNIEXPORT jobjectArray JNICALL Java_gnu_classpath_VMStackWalker_getClassContext(JNIEnv *env, jclass clazz)
55 java_handle_objectarray_t *oa;
57 oa = stacktrace_getClassContext();
59 return (jobjectArray) oa;
64 * Class: gnu/classpath/VMStackWalker
65 * Method: getCallingClass
66 * Signature: ()Ljava/lang/Class;
68 JNIEXPORT jclass JNICALL Java_gnu_classpath_VMStackWalker_getCallingClass(JNIEnv *env, jclass clazz)
72 c = stacktrace_get_caller_class(2);
79 * Class: gnu/classpath/VMStackWalker
80 * Method: getCallingClassLoader
81 * Signature: ()Ljava/lang/ClassLoader;
83 JNIEXPORT jobject JNICALL Java_gnu_classpath_VMStackWalker_getCallingClassLoader(JNIEnv *env, jclass clazz)
88 c = stacktrace_get_caller_class(2);
89 cl = class_get_classloader(c);
96 * Class: gnu/classpath/VMStackWalker
97 * Method: firstNonNullClassLoader
98 * Signature: ()Ljava/lang/ClassLoader;
100 JNIEXPORT jobject JNICALL Java_gnu_classpath_VMStackWalker_firstNonNullClassLoader(JNIEnv *env, jclass clazz)
104 cl = stacktrace_first_nonnull_classloader();
112 /* native methods implemented by this file ************************************/
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 },
122 /* _Jv_gnu_classpath_VMStackWalker_init ****************************************
124 Register native functions.
126 *******************************************************************************/
130 void _Jv_gnu_classpath_VMStackWalker_init(void)
134 u = utf_new_char("gnu/classpath/VMStackWalker");
136 native_method_register(u, methods, NATIVE_METHODS_COUNT);
142 * These are local overrides for various environment variables in Emacs.
143 * Please do not remove this and leave it at the end of the file, where
144 * Emacs will automagically detect them.
145 * ---------------------------------------------------------------------
148 * indent-tabs-mode: t
152 * vim:noexpandtab:sw=4:ts=4: