classpath-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [cp-patches] Native library class loader fixes


From: Archie Cobbs
Subject: Re: [cp-patches] Native library class loader fixes
Date: Tue, 04 Jan 2005 10:02:53 -0600
User-agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.7.3) Gecko/20041129

Jeroen Frijters wrote:
> Uh, oh yeah. I was going by my understanding of what the code should do
> instead of by what it actually does. It's broken, it should always try
> the libpath if findLibrary() returns null. Something like:
> 
> if (loader != null)
>   {
>     filename = loader.findLibrary(libname);
>     if (filename != null)
>       {
>         if (loadLib(filename, loader) != 0)
>           return;
>         else
>           throw new UnsatisfiedLinkError("Could not find library " +
> filename);
>       }
>   }
> filename = VMRuntime.mapLibraryName(libname);
> for (int i = 0; i < libpath.length; i++)
>   if (loadLib(libpath[i] + filename, loader) != 0)
>     return;
> throw new UnsatisfiedLinkError("Could not find library " + libname);

You're right.. I inadvertently changed the logic.

Attached is the updated patch with this fixed.

-Archie

__________________________________________________________________________
Archie Cobbs      *        CTO, Awarix        *      http://www.awarix.com


*
Confidentiality Notice: This e-mail message, including any attachments, is for 
the sole use of the intended recipient(s) and may contain confidential and 
privileged information. Any unauthorized review, use, disclosure or 
distribution is prohibited. If you are not the intended
recipient, please contact the sender by reply e-mail and destroy all copies of 
the original message.
*
Index: ChangeLog
===================================================================
RCS file: /cvsroot/classpath/classpath/ChangeLog,v
retrieving revision 1.3017
diff -u -r1.3017 ChangeLog
--- ChangeLog   3 Jan 2005 16:50:05 -0000       1.3017
+++ ChangeLog   4 Jan 2005 15:53:15 -0000
@@ -1,3 +1,24 @@
+2005-01-03  Archie Cobbs  <address@hidden>
+
+       * NEWS: Document changes.
+       * java/lang/Class.java (newInstance(), getClassLoader(),
+       forName(String), forName(String, boolean, ClassLoader)):
+       Use new VMStackWalker methods.
+       * java/lang/ClassLoader.java (getParent(), getSystemClassLoader()):
+       Likewise.
+       * java/lang/Package.java (getPackages()): Likewise.
+       * java/lang/SecurityManager.java (getClassContext()): Use new
+       VMStackWalker methods.
+       * java/util/ResourceBundle.java (getBundle()): Likewise.
+       * java/lang/Runtime.java (load(), loadLibrary()): Load the native
+       library using the calling class' class loader.
+       * java/lang/System.java (load(), loadLibrary()): Likewise.
+       (currentClassLoader()): implement via currentLoadedClass().
+       * vm/reference/gnu/classpath/VMStackWalker.java: New class.
+       * vm/reference/java/lang/VMRuntime.java (nativeLoad()):
+       Add a ClassLoader parameter.
+       * vm/reference/java/lang/VMSecurityManager.java: Removed.
+
 2005-01-03  Michael Koch  <address@hidden>
 
        * javax/swing/plaf/metal/MetalLookAndFeel.java
Index: NEWS
===================================================================
RCS file: /cvsroot/classpath/classpath/NEWS,v
retrieving revision 1.62
diff -u -r1.62 NEWS
--- NEWS        31 Dec 2004 21:32:17 -0000      1.62
+++ NEWS        4 Jan 2005 15:53:15 -0000
@@ -19,6 +19,11 @@
   implementation, but it is a generic implementation that ignores the
   nano-seconds argument. Runtime hackers are encouraged to provide a more
   efficient version.
+* VMRuntime.nativeLoad() now takes an additional ClassLoader parameter.
+* VMSecurityManager has been replaced by gnu.classpath.VMStackWalker.
+  currentClassLoader() is no longer needed, and there are also two new
+  methods with non-native implementations. VM implementors are encouraged
+  to provide more efficient versions.
 
 New in release 0.12 (Nov 14, 2004)
 
Index: java/lang/Class.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/lang/Class.java,v
retrieving revision 1.28
diff -u -r1.28 Class.java
--- java/lang/Class.java        27 Dec 2004 11:39:28 -0000      1.28
+++ java/lang/Class.java        4 Jan 2005 15:53:15 -0000
@@ -38,6 +38,8 @@
 
 package java.lang;
 
+import gnu.classpath.VMStackWalker;
+
 import java.io.InputStream;
 import java.io.Serializable;
 import java.lang.reflect.Constructor;
@@ -157,7 +159,7 @@
     Class result = VMClass.forName (name);
     if (result == null)
       result = Class.forName(name, true,
-                            
VMSecurityManager.getClassContext()[1].getClassLoader());
+       VMStackWalker.getCallingClassLoader());
     return result;
   }
 
@@ -198,9 +200,8 @@
         SecurityManager sm = SecurityManager.current;
         if (sm != null)
           {
-            // Get the calling class and classloader
-            Class c = VMSecurityManager.getClassContext()[1];
-            ClassLoader cl = c.getClassLoader();
+            // Get the calling classloader
+            ClassLoader cl = VMStackWalker.getCallingClassLoader();
             if (cl != null)
               sm.checkPermission(new RuntimePermission("getClassLoader"));
           }
@@ -278,9 +279,8 @@
     SecurityManager sm = SecurityManager.current;
     if (sm != null)
       {
-        // Get the calling class and classloader
-        Class c = VMSecurityManager.getClassContext()[1];
-        ClassLoader cl = VMClass.getClassLoader(c);
+        // Get the calling classloader
+       ClassLoader cl = VMStackWalker.getCallingClassLoader();
         if (cl != null && !cl.isAncestorOf(loader))
           sm.checkPermission(new RuntimePermission("getClassLoader"));
       }
@@ -1132,8 +1132,9 @@
     int modifiers = constructor.getModifiers();
     if (!Modifier.isPublic(modifiers))
       {
-       Class caller = VMSecurityManager.getClassContext()[1];
-       if (caller != this &&
+       Class caller = VMStackWalker.getCallingClass();
+       if (caller != null &&
+           caller != this &&
            (Modifier.isPrivate(modifiers)
             || getClassLoader() != caller.getClassLoader()
             || !getPackagePortion(getName())
Index: java/lang/ClassLoader.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/lang/ClassLoader.java,v
retrieving revision 1.40
diff -u -r1.40 ClassLoader.java
--- java/lang/ClassLoader.java  6 Dec 2004 20:43:13 -0000       1.40
+++ java/lang/ClassLoader.java  4 Jan 2005 15:53:15 -0000
@@ -39,6 +39,7 @@
 package java.lang;
 
 import gnu.classpath.SystemProperties;
+import gnu.classpath.VMStackWalker;
 import gnu.java.util.DoubleEnumeration;
 import gnu.java.util.EmptyEnumeration;
 
@@ -520,8 +521,7 @@
     SecurityManager sm = SecurityManager.current;
     if (sm != null)
       {
-        Class c = VMSecurityManager.getClassContext()[1];
-        ClassLoader cl = c.getClassLoader();
+       ClassLoader cl = VMStackWalker.getCallingClassLoader();
        if (cl != null && ! cl.isAncestorOf(this))
           sm.checkPermission(new RuntimePermission("getClassLoader"));
       }
@@ -763,8 +763,7 @@
     SecurityManager sm = SecurityManager.current;
     if (sm != null)
       {
-       Class c = VMSecurityManager.getClassContext()[1];
-       ClassLoader cl = c.getClassLoader();
+       ClassLoader cl = VMStackWalker.getCallingClassLoader();
        if (cl != null && cl != StaticData.systemClassLoader)
          sm.checkPermission(new RuntimePermission("getClassLoader"));
       }
Index: java/lang/Package.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/lang/Package.java,v
retrieving revision 1.12
diff -u -r1.12 Package.java
--- java/lang/Package.java      13 Oct 2004 08:24:05 -0000      1.12
+++ java/lang/Package.java      4 Jan 2005 15:53:15 -0000
@@ -37,6 +37,8 @@
 
 package java.lang;
 
+import gnu.classpath.VMStackWalker;
+
 import java.net.URL;
 import java.util.NoSuchElementException;
 import java.util.StringTokenizer;
@@ -273,7 +275,7 @@
   public static Package getPackage(String name)
   {
     // Get the caller's classloader
-    ClassLoader cl = VMSecurityManager.currentClassLoader();
+    ClassLoader cl = VMStackWalker.getCallingClassLoader();
     return cl != null ? cl.getPackage(name) : null;
   }
 
@@ -286,8 +288,7 @@
   public static Package[] getPackages()
   {
     // Get the caller's classloader
-    Class c = VMSecurityManager.getClassContext()[1];
-    ClassLoader cl = c.getClassLoader();
+    ClassLoader cl = VMStackWalker.getCallingClassLoader();
     // Sun's implementation returns the packages loaded by the bootstrap
     // classloader if cl is null, but right now our bootstrap classloader
     // does not create any Packages.
Index: java/lang/Runtime.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/lang/Runtime.java,v
retrieving revision 1.15
diff -u -r1.15 Runtime.java
--- java/lang/Runtime.java      29 Dec 2004 11:15:02 -0000      1.15
+++ java/lang/Runtime.java      4 Jan 2005 15:53:15 -0000
@@ -39,6 +39,7 @@
 package java.lang;
 
 import gnu.classpath.SystemProperties;
+import gnu.classpath.VMStackWalker;
 
 import java.io.File;
 import java.io.IOException;
@@ -628,16 +629,33 @@
    * before the final ".so" if the VM was invoked by the name "java_g". There
    * may be a security check, of <code>checkLink</code>.
    *
+   * <p>
+   * The library is loaded using the class loader associated with the
+   * class associated with the invoking method.
+   *
    * @param filename the file to load
    * @throws SecurityException if permission is denied
    * @throws UnsatisfiedLinkError if the library is not found
    */
   public void load(String filename)
   {
+    load(filename, VMStackWalker.getCallingClassLoader());
+  }
+
+  /**
+   * Same as <code>load(String)</code> but using the given loader.
+   *
+   * @param filename the file to load
+   * @param loader class loader, or <code>null</code> for the boot loader
+   * @throws SecurityException if permission is denied
+   * @throws UnsatisfiedLinkError if the library is not found
+   */
+  void load(String filename, ClassLoader loader)
+  {
     SecurityManager sm = SecurityManager.current; // Be thread-safe!
     if (sm != null)
       sm.checkLink(filename);
-    if (loadLib(filename) == 0)
+    if (loadLib(filename, loader) == 0)
       throw new UnsatisfiedLinkError("Could not load library " + filename);
   }
 
@@ -645,15 +663,16 @@
    * Do a security check on the filename and then load the native library.
    *
    * @param filename the file to load
+   * @param loader class loader, or <code>null</code> for the boot loader
    * @return 0 on failure, nonzero on success
    * @throws SecurityException if file read permission is denied
    */
-  private static int loadLib(String filename)
+  private static int loadLib(String filename, ClassLoader loader)
   {
     SecurityManager sm = SecurityManager.current; // Be thread-safe!
     if (sm != null)
       sm.checkRead(filename);
-    return VMRuntime.nativeLoad(filename);
+    return VMRuntime.nativeLoad(filename, loader);
   }
 
   /**
@@ -668,6 +687,10 @@
    * <code>System.mapLibraryName(libname)</code>. There may be a security
    * check, of <code>checkLink</code>.
    *
+   * <p>
+   * The library is loaded using the class loader associated with the
+   * class associated with the invoking method.
+   *
    * @param libname the library to load
    *
    * @throws SecurityException if permission is denied
@@ -678,30 +701,38 @@
    */
   public void loadLibrary(String libname)
   {
+    loadLibrary(libname, VMStackWalker.getCallingClassLoader());
+  }
+
+  /**
+   * Same as <code>loadLibrary(String)</code> but using the given loader.
+   *
+   * @param libname the library to load
+   * @param loader class loader, or <code>null</code> for the boot loader
+   * @throws SecurityException if permission is denied
+   * @throws UnsatisfiedLinkError if the library is not found
+   */
+  void loadLibrary(String libname, ClassLoader loader)
+  {
     SecurityManager sm = SecurityManager.current; // Be thread-safe!
     if (sm != null)
       sm.checkLink(libname);
-
     String filename;
-    ClassLoader cl = VMSecurityManager.currentClassLoader();
-    if (cl != null)
+    if (loader != null)
       {
-        filename = cl.findLibrary(libname);
+        filename = loader.findLibrary(libname);
         if (filename != null)
-          {
-            if (loadLib(filename) != 0)
+         {
+           if (loadLib(filename, loader) != 0)
              return;
-           else
-             throw new UnsatisfiedLinkError("Could not load library " + 
filename);
-          }
+           throw new UnsatisfiedLinkError("Could not find library " + libname);
+         }
       }
-
     filename = VMRuntime.mapLibraryName(libname);
     for (int i = 0; i < libpath.length; i++)
-      if (loadLib(libpath[i] + filename) != 0)
+      if (loadLib(libpath[i] + filename, loader) != 0)
        return;
-
-    throw new UnsatisfiedLinkError("Could not find library " + libname + ".");
+    throw new UnsatisfiedLinkError("Could not find library " + libname);
   }
 
   /**
Index: java/lang/SecurityManager.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/lang/SecurityManager.java,v
retrieving revision 1.23
diff -u -r1.23 SecurityManager.java
--- java/lang/SecurityManager.java      6 Dec 2004 20:43:13 -0000       1.23
+++ java/lang/SecurityManager.java      4 Jan 2005 15:53:15 -0000
@@ -38,6 +38,8 @@
 
 package java.lang;
 
+import gnu.classpath.VMStackWalker;
+
 import java.awt.AWTPermission;
 import java.io.File;
 import java.io.FileDescriptor;
@@ -179,7 +181,10 @@
    */
   protected Class[] getClassContext()
   {
-    return VMSecurityManager.getClassContext();
+    Class[] stack1 = VMStackWalker.getClassContext();
+    Class[] stack2 = new Class[stack1.length - 1];
+    System.arraycopy(stack1, 1, stack2, 0, stack1.length - 1);
+    return stack2;
   }
 
   /**
@@ -201,7 +206,8 @@
    */
   protected ClassLoader currentClassLoader()
   {
-    return VMSecurityManager.currentClassLoader();
+    Class cl = currentLoadedClass();
+    return cl != null ? cl.getClassLoader() : null;
   }
 
   /**
Index: java/lang/System.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/lang/System.java,v
retrieving revision 1.46
diff -u -r1.46 System.java
--- java/lang/System.java       29 Dec 2004 11:15:02 -0000      1.46
+++ java/lang/System.java       4 Jan 2005 15:53:15 -0000
@@ -39,6 +39,7 @@
 
 package java.lang;
 
+import gnu.classpath.VMStackWalker;
 import gnu.classpath.SystemProperties;
 
 import java.io.InputStream;
@@ -480,6 +481,10 @@
    * check may be performed, <code>checkLink</code>. This just calls
    * <code>Runtime.getRuntime().load(filename)</code>.
    *
+   * <p>
+   * The library is loaded using the class loader associated with the
+   * class associated with the invoking method.
+   *
    * @param filename the code file to load
    * @throws SecurityException if permission is denied
    * @throws UnsatisfiedLinkError if the file cannot be loaded
@@ -487,7 +492,7 @@
    */
   public static void load(String filename)
   {
-    Runtime.getRuntime().load(filename);
+    Runtime.getRuntime().load(filename, VMStackWalker.getCallingClassLoader());
   }
 
   /**
@@ -495,6 +500,10 @@
    * check may be performed, <code>checkLink</code>. This just calls
    * <code>Runtime.getRuntime().load(filename)</code>.
    *
+   * <p>
+   * The library is loaded using the class loader associated with the
+   * class associated with the invoking method.
+   *
    * @param libname the library file to load
    * @throws SecurityException if permission is denied
    * @throws UnsatisfiedLinkError if the file cannot be loaded
@@ -502,7 +511,8 @@
    */
   public static void loadLibrary(String libname)
   {
-    Runtime.getRuntime().loadLibrary(libname);
+    Runtime.getRuntime().loadLibrary(libname,
+      VMStackWalker.getCallingClassLoader());
   }
 
   /**
Index: java/util/ResourceBundle.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/util/ResourceBundle.java,v
retrieving revision 1.27
diff -u -r1.27 ResourceBundle.java
--- java/util/ResourceBundle.java       29 Dec 2004 11:15:02 -0000      1.27
+++ java/util/ResourceBundle.java       4 Jan 2005 15:53:15 -0000
@@ -39,6 +39,7 @@
 
 package java.util;
 
+import gnu.classpath.VMStackWalker;
 import java.io.IOException;
 import java.io.InputStream;
 import java.security.AccessController;
@@ -104,48 +105,6 @@
   private Locale locale;
 
   /**
-   * We override SecurityManager in order to access getClassContext().
-   */
-  private static final class Security extends SecurityManager
-  {
-    /**
-     * Avoid accessor method of private constructor.
-     */
-    Security()
-    {
-    }
-
-    /**
-     * Return the ClassLoader of the class which called into this
-     * ResourceBundle, or null if it cannot be determined.
-     */
-    ClassLoader getCallingClassLoader()
-    {
-      Class[] stack = getClassContext();
-      for (int i = 0; i < stack.length; i++)
-       {
-        if (stack[i] != Security.class && stack[i] != ResourceBundle.class)
-          return stack[i].getClassLoader();
-       }
-
-      return null;
-    }
-  }
-
-  /** A security context for grabbing the correct class loader. */
-  private static final Security security
-    = (Security) AccessController.doPrivileged(new PrivilegedAction()
-      {
-       // This will always work since java.util classes have (all) system
-       // permissions.
-       public Object run()
-       {
-         return new Security();
-       }
-      }
-    );
-
-  /**
    * The resource bundle cache.
    */
   private static Map bundleCache;
@@ -256,7 +215,7 @@
    */
   public static ResourceBundle getBundle(String baseName)
   {
-    ClassLoader cl = security.getCallingClassLoader();
+    ClassLoader cl = VMStackWalker.getCallingClassLoader();
     if (cl == null)
       cl = ClassLoader.getSystemClassLoader();
     return getBundle(baseName, Locale.getDefault(), cl);
@@ -276,7 +235,7 @@
    */
   public static ResourceBundle getBundle(String baseName, Locale locale)
   {
-    ClassLoader cl = security.getCallingClassLoader();
+    ClassLoader cl = VMStackWalker.getCallingClassLoader();
     if (cl == null)
       cl = ClassLoader.getSystemClassLoader();
     return getBundle(baseName, locale, cl);
Index: vm/reference/gnu/classpath/VMStackWalker.java
===================================================================
RCS file: vm/reference/gnu/classpath/VMStackWalker.java
diff -N vm/reference/gnu/classpath/VMStackWalker.java
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ vm/reference/gnu/classpath/VMStackWalker.java       4 Jan 2005 15:53:16 
-0000
@@ -0,0 +1,108 @@
+/* VMStackWalker.java -- Reference implementation of VM hooks for stack access
+   Copyright (C) 2004 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath;
+
+/**
+ * This class provides access to the classes on the Java stack
+ * for reflection and security purposes.
+ *
+ * <p>
+ * This class is only available to priviledged code (i.e., code loaded
+ * by the bootstrap loader).
+ *
+ * @author John Keiser
+ * @author Eric Blake <address@hidden>
+ * @author Archie Cobbs
+ */
+public final class VMStackWalker
+{
+  /**
+   * Get a list of all the classes currently executing methods on the
+   * Java stack. <code>getClassContext()[0]</code> is the class associated
+   * with the currently executing method, i.e., the method that called
+   * <code>VMStackWalker.getClassContext()</code> (possibly through
+   * reflection). So you may need to pop off these stack frames from
+   * the top of the stack:
+   * <ul>
+   * <li><code>VMStackWalker.getClassContext()</code>
+   * <li><code>Method.invoke()</code>
+   * </ul>
+   *
+   * @return an array of the declaring classes of each stack frame
+   */
+  public static native Class[] getClassContext();
+
+  /**
+   * Get the class associated with the method invoking the method
+   * invoking this method, or <code>null</code> if the stack is not
+   * that deep (e.g., invoked via JNI invocation API). This method
+   * is an optimization for the expression <code>getClassContext()[1]</code>
+   * and should return the same result.
+   *
+   * <p>
+   * VM implementers are encouraged to provide a more efficient
+   * version of this method.
+   */
+  public static Class getCallingClass()
+  {
+    Class[] ctx = getClassContext();
+    if (ctx.length < 3)
+      return null;
+    return ctx[2];
+  }
+
+  /**
+   * Get the class loader associated with the Class returned by
+   * <code>getCallingClass()</code>, or <code>null</code> if no
+   * such class exists or it is the boot loader. This method is an optimization
+   * for the expression <code>getClassContext()[1].getClassLoader()</code>
+   * and should return the same result.
+   *
+   * <p>
+   * VM implementers are encouraged to provide a more efficient
+   * version of this method.
+   */
+  public static ClassLoader getCallingClassLoader()
+  {
+    Class[] ctx = getClassContext();
+    if (ctx.length < 3)
+      return null;
+    return ctx[2].getClassLoader();
+  }
+}
+
Index: vm/reference/java/lang/VMRuntime.java
===================================================================
RCS file: /cvsroot/classpath/classpath/vm/reference/java/lang/VMRuntime.java,v
retrieving revision 1.7
diff -u -r1.7 VMRuntime.java
--- vm/reference/java/lang/VMRuntime.java       28 Dec 2004 10:28:27 -0000      
1.7
+++ vm/reference/java/lang/VMRuntime.java       4 Jan 2005 15:53:16 -0000
@@ -151,9 +151,10 @@
      * already been mapped to a true filename.
      *
      * @param filename the file to load
+     * @param loader class loader, or <code>null</code> for the boot loader
      * @return 0 on failure, nonzero on success
      */
-    static native int nativeLoad(String filename);
+    static native int nativeLoad(String filename, ClassLoader loader);
 
     /**
      * Map a system-independent "short name" to the full file name.
Index: vm/reference/java/lang/VMSecurityManager.java
===================================================================
RCS file: vm/reference/java/lang/VMSecurityManager.java
diff -N vm/reference/java/lang/VMSecurityManager.java
--- vm/reference/java/lang/VMSecurityManager.java       6 Mar 2002 19:44:44 
-0000       1.10
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,73 +0,0 @@
-/* VMSecurityManager.java -- Reference implementation of VM hooks for security
-   Copyright (C) 1998, 2002 Free Software Foundation
-
-This file is part of GNU Classpath.
-
-GNU Classpath is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU Classpath is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Classpath; see the file COPYING.  If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
-
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library.  Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module.  An independent module is a module which is not derived from
-or based on this library.  If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so.  If you do not wish to do so, delete this
-exception statement from your version. */
-
-package java.lang;
-
-/**
- * VMSecurityManager is a helper class for SecurityManager the VM must
- * implement.
- *
- * @author John Keiser
- * @author Eric Blake <address@hidden>
- */
-final class VMSecurityManager
-{
-  /**
-   * Get a list of all the classes currently executing methods on the
-   * Java stack.  getClassContext()[0] is the currently executing method, ie.
-   * the method which called SecurityManager.getClassContext().  (Hint: you
-   * may need to pop off one or more frames: don't include SecurityManager
-   * or VMSecurityManager.getClassContext in your result. Also, be sure that
-   * you correctly handle the context if SecurityManager.getClassContext
-   * was invoked by reflection).
-   *
-   * @return an array of the declaring classes of each stack frame
-   */
-  static native Class[] getClassContext();
-
-  /**
-   * Get the current ClassLoader. This is the first non-null class loader
-   * on the stack, if one exists, stopping either at the end of the stack
-   * or the first instance of a PrivilegedAction. In other words, this call
-   * automatically unwinds past all classes loaded by the bootstrap loader,
-   * where getClassLoader() returns null, to get to the user class that
-   * really invoked the call that needs a classloader.
-   *
-   * @return the current ClassLoader
-   */
-  static native ClassLoader currentClassLoader();
-}

reply via email to

[Prev in Thread] Current Thread [Next in Thread]