/[classpath]/classpath/java/lang/ClassLoader.java
ViewVC logotype

Diff of /classpath/java/lang/ClassLoader.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.21 by tromey, Thu Dec 12 01:00:22 2002 UTC revision 1.22 by jewel, Wed Dec 18 10:28:29 2002 UTC
# Line 145  public abstract class ClassLoader Line 145  public abstract class ClassLoader
145     * is somewhat circular - getSystemClassLoader() checks whether this     * is somewhat circular - getSystemClassLoader() checks whether this
146     * field is null in order to bypass a security check.     * field is null in order to bypass a security check.
147     */     */
148    static final ClassLoader systemClassLoader = getSystemClassLoader();    static final ClassLoader systemClassLoader = VMClassLoader.getSystemClassLoader();
149    
150    /**    /**
151     * The default protection domain, used when defining a class with a null     * The default protection domain, used when defining a class with a null
# Line 744  public abstract class ClassLoader Line 744  public abstract class ClassLoader
744     */     */
745    public static ClassLoader getSystemClassLoader()    public static ClassLoader getSystemClassLoader()
746    {    {
747      // This method is called as the initialization of systemClassLoader,       // Check if we may return the system classloader
748      // so if there is a null value, this is the first call and we must check        SecurityManager sm = System.getSecurityManager();
749      // for java.system.class.loader.        if (sm != null)
750      if (systemClassLoader == null)            {
751        {                Class c = VMSecurityManager.getClassContext()[1];
752          String loader = System.getProperty("java.system.class.loader",                ClassLoader cl = c.getClassLoader();
753                                             "gnu.java.lang.SystemClassLoader");                if (cl != null && cl != systemClassLoader)
754          try                    sm.checkPermission(new RuntimePermission("getClassLoader"));
755            {            }
756              // Give the new system class loader a null parent.  
757              Constructor c = Class.forName(loader).getConstructor        return systemClassLoader;
               ( new Class[] { ClassLoader.class } );  
             return (ClassLoader) c.newInstance(new Object[1]);  
           }  
         catch (Exception e)  
           {  
             try  
               {  
                 System.err.println("Requested system classloader "  
                                    + loader + " failed, trying "  
                                    + "gnu.java.lang.SystemClassLoader");  
                 e.printStackTrace();  
                 // Fallback to gnu.java.lang.SystemClassLoader.  
                 return new SystemClassLoader(null);  
               }  
             catch (Exception e1)  
               {  
                 throw (Error) new InternalError  
                   ("System class loader could not be found: " + e1)  
                   .initCause(e1);  
               }  
           }  
       }  
     // Check if we may return the system classloader  
     SecurityManager sm = System.getSecurityManager();  
     if (sm != null)  
       {  
         Class c = VMSecurityManager.getClassContext()[1];  
         ClassLoader cl = c.getClassLoader();  
         if (cl != null && cl != systemClassLoader)  
           sm.checkPermission(new RuntimePermission("getClassLoader"));  
       }  
     return systemClassLoader;  
758    }    }
759    
760    /**    /**

Legend:
Removed from v.1.21  
changed lines
  Added in v.1.22

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26