OpenCores
URL https://opencores.org/ocsvn/scarts/scarts/trunk

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-gcc/] [gcc-4.1.1/] [libjava/] [java/] [lang/] [VMSecurityManager.java] - Blame information for rev 14

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 14 jlechner
/*
2
 * java.lang.SecurityManager: part of the Java Class Libraries project.
3
 * Copyright (C) 1998, 2001, 2002, 2005 Free Software Foundation
4
 *
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.
9
 *
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.
14
 *
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.
19
 */
20
 
21
package java.lang;
22
 
23
import java.net.*;
24
import java.util.*;
25
import java.io.*;
26
 
27
/**
28
 ** VMSecurityManager is a helper class for SecurityManager the VM must
29
 ** implement.
30
 **
31
 ** @author  John Keiser
32
 ** @version 1.1.0, 31 May 1998
33
 **/
34
class VMSecurityManager
35
{
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.
42
   **
43
   ** @return an array containing all the methods on classes
44
   **         on the Java execution stack.
45
   **/
46
  static native Class[] getClassContext(Class caller);
47
 
48
  /** Get the current ClassLoader--the one nearest to the
49
   ** top of the stack.
50
   ** @return the current ClassLoader.
51
   **/
52
  static ClassLoader currentClassLoader(Class caller)
53
  {
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++)
60
      {
61
        ClassLoader loader = classStack[i].getClassLoader();
62
        if (loader != null && loader != systemClassLoader)
63
          return loader;
64
      }
65
 
66
    return null;
67
  }
68
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.