[jboss-cvs] JBossAS SVN: r60293 - branches/JBoss_4_0_3_SP1_JBAS-4061/common/src/main/org/jboss/util/loading.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Feb 5 09:38:36 EST 2007


Author: darran.lofthouse at jboss.com
Date: 2007-02-05 09:38:36 -0500 (Mon, 05 Feb 2007)
New Revision: 60293

Modified:
   branches/JBoss_4_0_3_SP1_JBAS-4061/common/src/main/org/jboss/util/loading/DelegatingClassLoader.java
Log:
JBAS-4061 - If parent classloader does not return class attempt to load it with this classloader.

Modified: branches/JBoss_4_0_3_SP1_JBAS-4061/common/src/main/org/jboss/util/loading/DelegatingClassLoader.java
===================================================================
--- branches/JBoss_4_0_3_SP1_JBAS-4061/common/src/main/org/jboss/util/loading/DelegatingClassLoader.java	2007-02-05 14:17:12 UTC (rev 60292)
+++ branches/JBoss_4_0_3_SP1_JBAS-4061/common/src/main/org/jboss/util/loading/DelegatingClassLoader.java	2007-02-05 14:38:36 UTC (rev 60293)
@@ -24,11 +24,11 @@
  * @author <a href="mailto:adrian at jboss.org">Adrian Brock</a>
  * @version $Revision$
  */
-public class DelegatingClassLoader
-   extends URLClassLoader
+public class DelegatingClassLoader extends URLClassLoader
 {
    /** The value returned by {@link getURLs}. */
-   public static final URL[] EMPTY_URL_ARRAY = {};
+   public static final URL[] EMPTY_URL_ARRAY =
+   {};
 
    /** Whether to use standard loading */
    protected boolean standard = false;
@@ -66,17 +66,28 @@
     * @return the loaded class
     * @throws ClassNotFoundException when the class could not be found
     */
-   protected Class loadClass(String className, boolean resolve)
-      throws ClassNotFoundException
+   protected Class loadClass(String className, boolean resolve) throws ClassNotFoundException
    {
-      // Revert to standard rules
+      //    Revert to standard rules
       if (standard)
          return super.loadClass(className, resolve);
 
-      // Ask the parent
-      Class clazz = getParent().loadClass(className);
+      //    Ask the parent
+      Class clazz = null;
+      try
+      {
+         clazz = getParent().loadClass(className);
+      }
+      catch (ClassNotFoundException e)
+      {
+         //    Not found in parent,
+         //    maybe it is a proxy registered against this classloader?
+         clazz = findLoadedClass(className);
+         if (clazz == null)
+            throw e;
+      }
 
-      // Link the class
+      //    Link the class
       if (resolve)
          resolveClass(clazz);
 




More information about the jboss-cvs-commits mailing list