ed5207e17baee4787f7e91c9bd9ecd0eac26553f
[cacao.git] / nat / VMSecurityManager.c
1 /* nat/SecurityManager.c - java/lang/SecurityManager
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 977 2004-03-25 18:37:52Z twisti $
32
33 */
34
35
36 #include "jni.h"
37 #include "builtin.h"
38 #include "native.h"
39 #include "tables.h"
40 #include "toolbox/loging.h"
41 #include "java_lang_ClassLoader.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         init_systemclassloader();
54
55         return SystemClassLoader;
56 }
57 #endif
58
59
60 #ifndef __I386__
61 /*THIS IS IN ASMPART NOW*/
62 /*
63  * Class:     java/lang/SecurityManager
64  * Method:    getClassContext
65  * Signature: ()[Ljava/lang/Class;
66  */
67 JNIEXPORT java_objectarray* JNICALL Java_java_lang_VMSecurityManager_getClassContext(JNIEnv *env, jclass clazz)
68 {
69   log_text("Java_java_lang_VMSecurityManager_getClassContext  called");
70
71   /* XXX should use vftbl directly */
72   return (java_objectarray *) builtin_newarray(0, class_array_of(class_java_lang_Class)->vftbl);
73 }
74 #endif
75
76 java_objectarray* temporaryGetClassContextHelper(methodinfo *m) {
77         if (!m) {
78                 log_text("BUILTIN");
79                 return 0;
80         }
81         if (!(m->name)) log_text("method or block has no name");
82         else
83         utf_display(m->name);
84         printf("--");  
85         if (!(m->class)) log_text("method or block has no class");
86         else
87         utf_display(m->class->name);
88         printf("\n");  
89 #if 0
90   log_text("temporaryGetClassContextHelper called");
91   if (adr==0) log_text("NO REAL METHOD");
92   else {
93         
94         struct methodinfo *m=(struct methodinfo*)(*(adr-1));
95         if (!(m->name)) log_text("method or block has no name");
96         else
97         utf_display(m->name);
98         if (!(m->class)) log_text("method or block has no class");
99         else
100         utf_display(m->class->name);
101         printf("\nFrame size:%ld\n",(long)(*(adr-2)));
102         adr=adr-5;
103         printf("saveint:%ld\n",(long)(*adr));
104         printf("saveflt:%ld\n",(long)(*(adr-1)));
105   }
106   log_text("temporaryGetClassContextHelper leaving");
107   return (java_objectarray *) builtin_newarray(0, class_array_of(class_java_lang_Class)->vftbl);        
108 #endif
109 }
110
111 java_objectarray* temporaryGetClassContextHelper2() {
112   log_text("temporaryGetClassContextHelper2 called");
113   return (java_objectarray *) builtin_newarray(0, class_array_of(class_java_lang_Class)->vftbl);        
114 }
115
116 /*
117  * These are local overrides for various environment variables in Emacs.
118  * Please do not remove this and leave it at the end of the file, where
119  * Emacs will automagically detect them.
120  * ---------------------------------------------------------------------
121  * Local variables:
122  * mode: c
123  * indent-tabs-mode: t
124  * c-basic-offset: 4
125  * tab-width: 4
126  * End:
127  */