commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rsi...@apache.org
Subject cvs commit: jakarta-commons/discovery/src/java/org/apache/commons/discovery/jdk JDK12Hooks.java
Date Sat, 05 Apr 2003 02:39:18 GMT
rsitze      2003/04/04 18:39:18

  Modified:    discovery/src/java/org/apache/commons/discovery/jdk
                        JDK12Hooks.java
  Log:
  Apparently ClassLoader.getSystemClassLoader() can return null in some situations?
  guard against that.
  
  Revision  Changes    Path
  1.3       +24 -13    jakarta-commons/discovery/src/java/org/apache/commons/discovery/jdk/JDK12Hooks.java
  
  Index: JDK12Hooks.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/discovery/src/java/org/apache/commons/discovery/jdk/JDK12Hooks.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- JDK12Hooks.java	12 Dec 2002 22:35:39 -0000	1.2
  +++ JDK12Hooks.java	5 Apr 2003 02:39:18 -0000	1.3
  @@ -70,6 +70,9 @@
    * @author Richard A. Sitze
    */
   class JDK12Hooks extends JDKHooks {
  +    private static final ClassLoader systemClassLoader
  +        = findSystemClassLoader();
  +
       /**
        * The thread context class loader is available for JDK 1.2
        * or later, if certain security conditions are met.
  @@ -109,19 +112,7 @@
        *         Otherwise return null.
        */
       public ClassLoader getSystemClassLoader() {
  -        ClassLoader classLoader;
  -        
  -        try {
  -            classLoader = ClassLoader.getSystemClassLoader();
  -        } catch (SecurityException e) {
  -            /**
  -             * Ignore and keep going.
  -             */
  -            classLoader = null;  // ignore
  -        }
  -        
  -        // Return the selected class loader
  -        return classLoader;
  +        return systemClassLoader;
       }
   
       /**
  @@ -206,5 +197,25 @@
                   return n;
               }
           };
  +    }
  +    
  +    static private ClassLoader findSystemClassLoader() {
  +        ClassLoader classLoader;
  +        
  +        try {
  +            classLoader = ClassLoader.getSystemClassLoader();
  +        } catch (SecurityException e) {
  +            /**
  +             * Ignore and keep going.
  +             */
  +            classLoader = null;
  +        }
  +
  +        if (classLoader == null) {
  +            classLoader = new PsuedoSystemClassLoader();
  +        }
  +        
  +        // Return the selected class loader
  +        return classLoader;
       }
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message