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