43f6bd55bb48363f31708a276be33f50f0550eff
[cacao.git] / src / native / vm / gnu / java_security_VMAccessController.c
1 /* src/native/vm/gnu/java_security_VMAccessController.c
2
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
7
8    This file is part of CACAO.
9
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.
14
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.
19
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
23    02110-1301, USA.
24
25    $Id: java_security_VMAccessController.c 7246 2007-01-29 18:49:05Z twisti $
26
27 */
28
29
30 #include "config.h"
31 #include "vm/types.h"
32
33 #include "native/jni.h"
34
35 #include "vm/builtin.h"
36
37 #include "vm/jit/stacktrace.h"
38
39 #include "vmcore/class.h"
40 #include "vmcore/options.h"
41
42
43 /*
44  * Class:     java/security/VMAccessController
45  * Method:    getStack
46  * Signature: ()[[Ljava/lang/Object;
47  */
48 JNIEXPORT java_objectarray* JNICALL Java_java_security_VMAccessController_getStack(JNIEnv *env, jclass clazz) {
49 #if defined(__ALPHA__) || defined(__ARM__) || defined(__I386__) || defined(__MIPS__) || defined(__POWERPC__) || defined (__X86_64__)
50         /* these JITs support stacktraces */
51
52         return stacktrace_getStack();
53
54 #else
55 # if defined(ENABLE_INTRP)
56         /* the interpreter supports stacktraces, even if the JIT does not */
57
58         if (opt_intrp) {
59                 return stacktrace_getStack();
60
61         } else
62 # endif
63                 {
64                         java_objectarray *result;
65                         java_objectarray *classes;
66                         java_objectarray *methodnames;
67
68                         if (!(result = builtin_anewarray(2, arrayclass_java_lang_Object)))
69                                 return NULL;
70
71                         if (!(classes = builtin_anewarray(0, class_java_lang_Class)))
72                                 return NULL;
73
74                         if (!(methodnames = builtin_anewarray(0, class_java_lang_String)))
75                                 return NULL;
76
77                         result->data[0] = (java_objectheader *) classes;
78                         result->data[1] = (java_objectheader *) methodnames;
79
80                         return result;
81                 }
82 #endif
83 }
84
85
86 /*
87  * These are local overrides for various environment variables in Emacs.
88  * Please do not remove this and leave it at the end of the file, where
89  * Emacs will automagically detect them.
90  * ---------------------------------------------------------------------
91  * Local variables:
92  * mode: c
93  * indent-tabs-mode: t
94  * c-basic-offset: 4
95  * tab-width: 4
96  * End:
97  */