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 7918 2007-05-20 20:42:18Z michi $
32 #include "native/jni.h"
33 #include "native/native.h"
35 #include "native/include/java_lang_Class.h"
36 #include "native/include/java_lang_ClassLoader.h"
38 #include "native/include/gnu_classpath_VMStackWalker.h"
40 #include "vm/builtin.h"
41 #include "vm/global.h"
43 #include "vm/jit/stacktrace.h"
45 #include "vmcore/class.h"
48 /* native methods implemented by this file ************************************/
50 static JNINativeMethod methods[] = {
51 { "getClassContext", "()[Ljava/lang/Class;", (void *) (ptrint) &Java_gnu_classpath_VMStackWalker_getClassContext },
52 { "getCallingClass", "()Ljava/lang/Class;", (void *) (ptrint) &Java_gnu_classpath_VMStackWalker_getCallingClass },
53 { "getCallingClassLoader", "()Ljava/lang/ClassLoader;", (void *) (ptrint) &Java_gnu_classpath_VMStackWalker_getCallingClassLoader },
54 { "firstNonNullClassLoader", "()Ljava/lang/ClassLoader;", (void *) (ptrint) &Java_gnu_classpath_VMStackWalker_firstNonNullClassLoader },
58 /* _Jv_gnu_classpath_VMStackWalker_init ****************************************
60 Register native functions.
62 *******************************************************************************/
64 void _Jv_gnu_classpath_VMStackWalker_init(void)
68 u = utf_new_char("gnu/classpath/VMStackWalker");
70 native_method_register(u, methods, NATIVE_METHODS_COUNT);
75 * Class: gnu/classpath/VMStackWalker
76 * Method: getClassContext
77 * Signature: ()[Ljava/lang/Class;
79 JNIEXPORT java_objectarray* JNICALL Java_gnu_classpath_VMStackWalker_getClassContext(JNIEnv *env, jclass clazz)
83 oa = stacktrace_getClassContext();
90 * Class: gnu/classpath/VMStackWalker
91 * Method: getCallingClass
92 * Signature: ()Ljava/lang/Class;
94 JNIEXPORT java_lang_Class* JNICALL Java_gnu_classpath_VMStackWalker_getCallingClass(JNIEnv *env, jclass clazz)
98 oa = stacktrace_getClassContext();
103 if (oa->header.size < 2)
106 return (java_lang_Class *) oa->data[1];
111 * Class: gnu/classpath/VMStackWalker
112 * Method: getCallingClassLoader
113 * Signature: ()Ljava/lang/ClassLoader;
115 JNIEXPORT java_lang_ClassLoader* JNICALL Java_gnu_classpath_VMStackWalker_getCallingClassLoader(JNIEnv *env, jclass clazz)
117 java_objectarray *oa;
121 oa = stacktrace_getClassContext();
126 if (oa->header.size < 2)
129 c = (classinfo *) oa->data[1];
135 return (java_lang_ClassLoader *) cl->object;
140 * Class: gnu/classpath/VMStackWalker
141 * Method: firstNonNullClassLoader
142 * Signature: ()Ljava/lang/ClassLoader;
144 JNIEXPORT java_lang_ClassLoader* JNICALL Java_gnu_classpath_VMStackWalker_firstNonNullClassLoader(JNIEnv *env, jclass clazz)
146 java_objectarray *oa;
151 oa = stacktrace_getClassContext();
156 for (i = 0; i < oa->header.size; i++) {
157 c = (classinfo *) oa->data[i];
161 return (java_lang_ClassLoader *) cl->object;
169 * These are local overrides for various environment variables in Emacs.
170 * Please do not remove this and leave it at the end of the file, where
171 * Emacs will automagically detect them.
172 * ---------------------------------------------------------------------
175 * indent-tabs-mode: t
179 * vim:noexpandtab:sw=4:ts=4: