1 /* src/native/vm/gnu/gnu_classpath_VMStackWalker.c
3 Copyright (C) 1996-2005, 2006, 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
25 $Id: gnu_classpath_VMStackWalker.c 8318 2007-08-16 10:05:34Z michi $
32 #include "native/jni.h"
33 #include "native/llni.h"
34 #include "native/native.h"
36 #include "native/include/java_lang_Class.h"
37 #include "native/include/java_lang_ClassLoader.h"
39 #include "native/include/gnu_classpath_VMStackWalker.h"
41 #include "vm/builtin.h"
42 #include "vm/global.h"
44 #include "vm/jit/stacktrace.h"
46 #include "vmcore/class.h"
49 /* native methods implemented by this file ************************************/
51 static JNINativeMethod methods[] = {
52 { "getClassContext", "()[Ljava/lang/Class;", (void *) (ptrint) &Java_gnu_classpath_VMStackWalker_getClassContext },
53 { "getCallingClass", "()Ljava/lang/Class;", (void *) (ptrint) &Java_gnu_classpath_VMStackWalker_getCallingClass },
54 { "getCallingClassLoader", "()Ljava/lang/ClassLoader;", (void *) (ptrint) &Java_gnu_classpath_VMStackWalker_getCallingClassLoader },
55 { "firstNonNullClassLoader", "()Ljava/lang/ClassLoader;", (void *) (ptrint) &Java_gnu_classpath_VMStackWalker_firstNonNullClassLoader },
59 /* _Jv_gnu_classpath_VMStackWalker_init ****************************************
61 Register native functions.
63 *******************************************************************************/
65 void _Jv_gnu_classpath_VMStackWalker_init(void)
69 u = utf_new_char("gnu/classpath/VMStackWalker");
71 native_method_register(u, methods, NATIVE_METHODS_COUNT);
76 * Class: gnu/classpath/VMStackWalker
77 * Method: getClassContext
78 * Signature: ()[Ljava/lang/Class;
80 JNIEXPORT java_handle_objectarray_t* JNICALL Java_gnu_classpath_VMStackWalker_getClassContext(JNIEnv *env, jclass clazz)
82 java_handle_objectarray_t *oa;
84 oa = stacktrace_getClassContext();
91 * Class: gnu/classpath/VMStackWalker
92 * Method: getCallingClass
93 * Signature: ()Ljava/lang/Class;
95 JNIEXPORT java_lang_Class* JNICALL Java_gnu_classpath_VMStackWalker_getCallingClass(JNIEnv *env, jclass clazz)
97 java_handle_objectarray_t *oa;
100 oa = stacktrace_getClassContext();
105 if (LLNI_array_size(oa) < 2)
108 LLNI_objectarray_element_get(oa, 1, o);
110 return (java_lang_Class *) o;
115 * Class: gnu/classpath/VMStackWalker
116 * Method: getCallingClassLoader
117 * Signature: ()Ljava/lang/ClassLoader;
119 JNIEXPORT java_lang_ClassLoader* JNICALL Java_gnu_classpath_VMStackWalker_getCallingClassLoader(JNIEnv *env, jclass clazz)
121 java_handle_objectarray_t *oa;
125 oa = stacktrace_getClassContext();
130 if (LLNI_array_size(oa) < 2)
133 c = (classinfo *) LLNI_array_direct(oa, 1);
136 return (java_lang_ClassLoader *) cl;
141 * Class: gnu/classpath/VMStackWalker
142 * Method: firstNonNullClassLoader
143 * Signature: ()Ljava/lang/ClassLoader;
145 JNIEXPORT java_lang_ClassLoader* JNICALL Java_gnu_classpath_VMStackWalker_firstNonNullClassLoader(JNIEnv *env, jclass clazz)
147 java_handle_objectarray_t *oa;
152 oa = stacktrace_getClassContext();
157 for (i = 0; i < LLNI_array_size(oa); i++) {
158 c = (classinfo *) LLNI_array_direct(oa, i);
162 return (java_lang_ClassLoader *) cl;
170 * These are local overrides for various environment variables in Emacs.
171 * Please do not remove this and leave it at the end of the file, where
172 * Emacs will automagically detect them.
173 * ---------------------------------------------------------------------
176 * indent-tabs-mode: t
180 * vim:noexpandtab:sw=4:ts=4: