GNU header update.
[cacao.git] / src / native / vm / VMSecurityManager.c
1 /* native/vm/VMSecurityManager.c - java/lang/VMSecurityManager
2
3    Copyright (C) 1996-2005 R. Grafl, A. Krall, C. Kruegel, C. Oates,
4    R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner,
5    C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger,
6    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., 59 Temple Place - Suite 330, Boston, MA
23    02111-1307, USA.
24
25    Contact: cacao@complang.tuwien.ac.at
26
27    Authors: Roman Obermaiser
28
29    Changes: Joseph Wenninger
30
31    $Id: VMSecurityManager.c 1735 2004-12-07 14:33:27Z twisti $
32
33 */
34
35
36 #include "native/jni.h"
37 #include "native/native.h"
38 #include "native/include/java_lang_ClassLoader.h"
39 #include "toolbox/logging.h"
40 #include "vm/builtin.h"
41 #include "vm/tables.h"
42 #include "vm/jit/stacktrace.h"
43
44
45 /*
46  * Class:     java/lang/VMSecurityManager
47  * Method:    currentClassLoader
48  * Signature: ()Ljava/lang/ClassLoader;
49  */
50 JNIEXPORT java_lang_ClassLoader* JNICALL Java_java_lang_VMSecurityManager_currentClassLoader(JNIEnv *env, jclass clazz)
51 {
52         log_text("Java_java_lang_VMSecurityManager_currentClassLoader");
53
54         if (cacao_initializing)
55                 return NULL;
56
57 #if defined(__I386__) || defined(__ALPHA__)
58         return (java_lang_ClassLoader *) cacao_currentClassLoader();
59 #else
60 /*      return 0; */
61         /* XXX TWISTI: only a quick hack */
62         init_systemclassloader();
63         return SystemClassLoader;
64 #endif
65 }
66
67
68 /*
69  * Class:     java/lang/VMSecurityManager
70  * Method:    getClassContext
71  * Signature: ()[Ljava/lang/Class;
72  */
73 JNIEXPORT java_objectarray* JNICALL Java_java_lang_VMSecurityManager_getClassContext(JNIEnv *env, jclass clazz)
74 {
75         log_text("Java_java_lang_VMSecurityManager_getClassContext  called");
76         if (cacao_initializing) return 0;
77 #if defined(__I386__) || defined(__ALPHA__)
78         return cacao_createClassContextArray();
79 #else
80 /*      return 0; */
81
82         /* XXX TWISTI: only a quick hack */
83         return (java_objectarray *) builtin_newarray(0, class_array_of(class_java_lang_Class)->vftbl);
84 #endif
85 }
86
87 java_objectarray* temporaryGetClassContextHelper(methodinfo *m) {
88         if (!m) {
89                 log_text("BUILTIN");
90                 return 0;
91         }
92         if (!(m->name)) log_text("method or block has no name");
93         else
94         utf_display(m->name);
95         printf("--");  
96         if (!(m->class)) log_text("method or block has no class");
97         else
98         utf_display(m->class->name);
99         printf("\n");
100         return NULL;
101 #if 0
102   log_text("temporaryGetClassContextHelper called");
103   if (adr==0) log_text("NO REAL METHOD");
104   else {
105         
106         struct methodinfo *m=(struct methodinfo*)(*(adr-1));
107         if (!(m->name)) log_text("method or block has no name");
108         else
109         utf_display(m->name);
110         if (!(m->class)) log_text("method or block has no class");
111         else
112         utf_display(m->class->name);
113         printf("\nFrame size:%ld\n",(long)(*(adr-2)));
114         adr=adr-5;
115         printf("saveint:%ld\n",(long)(*adr));
116         printf("saveflt:%ld\n",(long)(*(adr-1)));
117   }
118   log_text("temporaryGetClassContextHelper leaving");
119   return (java_objectarray *) builtin_newarray(0, class_array_of(class_java_lang_Class)->vftbl);
120 #endif
121 }
122
123
124 java_objectarray* temporaryGetClassContextHelper2() {
125   log_text("temporaryGetClassContextHelper2 called");
126   return (java_objectarray *) builtin_newarray(0, class_array_of(class_java_lang_Class)->vftbl);        
127 }
128
129
130 /*
131  * These are local overrides for various environment variables in Emacs.
132  * Please do not remove this and leave it at the end of the file, where
133  * Emacs will automagically detect them.
134  * ---------------------------------------------------------------------
135  * Local variables:
136  * mode: c
137  * indent-tabs-mode: t
138  * c-basic-offset: 4
139  * tab-width: 4
140  * End:
141  */