New source tree.
[cacao.git] / src / native / vm / VMSecurityManager.c
1 /* native/vm/VMSecurityManager.c - java/lang/VMSecurityManager
2
3    Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
4    R. Grafl, A. Krall, C. Kruegel, C. Oates, R. Obermaisser,
5    M. Probst, S. Ring, E. Steiner, C. Thalinger, D. Thuernbeck,
6    P. Tomsich, J. Wenninger
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 1621 2004-11-30 13:06:55Z 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
43
44 #ifndef __I386__
45 /*
46  * Class:     java/lang/SecurityManager
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         /* XXX TWISTI temporary hack! FIX ME jowenn */
55         if (cacao_initializing)
56                 return NULL;
57
58         init_systemclassloader();
59
60         return SystemClassLoader;
61 }
62 #endif
63
64
65 #ifndef __I386__
66 /*THIS IS IN ASMPART NOW*/
67 /*
68  * Class:     java/lang/SecurityManager
69  * Method:    getClassContext
70  * Signature: ()[Ljava/lang/Class;
71  */
72 JNIEXPORT java_objectarray* JNICALL Java_java_lang_VMSecurityManager_getClassContext(JNIEnv *env, jclass clazz)
73 {
74   log_text("Java_java_lang_VMSecurityManager_getClassContext  called");
75
76   /* XXX should use vftbl directly */
77   return (java_objectarray *) builtin_newarray(0, class_array_of(class_java_lang_Class)->vftbl);
78 }
79 #endif
80
81 java_objectarray* temporaryGetClassContextHelper(methodinfo *m) {
82         if (!m) {
83                 log_text("BUILTIN");
84                 return 0;
85         }
86         if (!(m->name)) log_text("method or block has no name");
87         else
88         utf_display(m->name);
89         printf("--");  
90         if (!(m->class)) log_text("method or block has no class");
91         else
92         utf_display(m->class->name);
93         printf("\n");  
94 #if 0
95   log_text("temporaryGetClassContextHelper called");
96   if (adr==0) log_text("NO REAL METHOD");
97   else {
98         
99         struct methodinfo *m=(struct methodinfo*)(*(adr-1));
100         if (!(m->name)) log_text("method or block has no name");
101         else
102         utf_display(m->name);
103         if (!(m->class)) log_text("method or block has no class");
104         else
105         utf_display(m->class->name);
106         printf("\nFrame size:%ld\n",(long)(*(adr-2)));
107         adr=adr-5;
108         printf("saveint:%ld\n",(long)(*adr));
109         printf("saveflt:%ld\n",(long)(*(adr-1)));
110   }
111   log_text("temporaryGetClassContextHelper leaving");
112   return (java_objectarray *) builtin_newarray(0, class_array_of(class_java_lang_Class)->vftbl);        
113 #endif
114 }
115
116 java_objectarray* temporaryGetClassContextHelper2() {
117   log_text("temporaryGetClassContextHelper2 called");
118   return (java_objectarray *) builtin_newarray(0, class_array_of(class_java_lang_Class)->vftbl);        
119 }
120
121 /*
122  * These are local overrides for various environment variables in Emacs.
123  * Please do not remove this and leave it at the end of the file, where
124  * Emacs will automagically detect them.
125  * ---------------------------------------------------------------------
126  * Local variables:
127  * mode: c
128  * indent-tabs-mode: t
129  * c-basic-offset: 4
130  * tab-width: 4
131  * End:
132  */