2 * java.lang.SecurityManager: part of the Java Class Libraries project.
3 * Copyright (C) 1998, 2001, 2002, 2005 Free Software Foundation
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
15 * You should have received a copy of the GNU Library General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
28 ** VMSecurityManager is a helper class for SecurityManager the VM must
31 ** @author John Keiser
32 ** @version 1.1.0, 31 May 1998
34 class VMSecurityManager
36 /** Get a list of all the classes currently executing
37 ** methods on the Java stack. getClassContext()[0] is
38 ** the currently executing method
39 ** <STRONG>Spec Note:</STRONG> does not say whether
40 ** the stack will include the getClassContext() call or
41 ** the one just before it.
43 ** @return an array containing all the methods on classes
44 ** on the Java execution stack.
46 static native Class
[] getClassContext(Class caller
);
48 /** Get the current ClassLoader--the one nearest to the
50 ** @return the current ClassLoader.
52 static ClassLoader
currentClassLoader(Class caller
)
54 // The docs above are wrong. See the online docs.
55 // FIXME this implementation is a bit wrong too -- the docs say we
56 // must also consider ancestors of the system class loader.
57 ClassLoader systemClassLoader
= ClassLoader
.systemClassLoader
;
58 Class
[] classStack
= getClassContext (caller
);
59 for (int i
= 0; i
< classStack
.length
; i
++)
61 ClassLoader loader
= classStack
[i
].getClassLoader();
62 if (loader
!= null && loader
!= systemClassLoader
)