tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jon Stevens <...@latchkey.com>
Subject [PATCH]: CVS update: jserv/src/java/org/apache/java/lang AdaptiveClassLoader.java
Date Sat, 17 Jun 2000 19:47:04 GMT
below is two patches. the first one is described in the Log:. the second one
fixes a minor issue with the first one.

please consider it for tomcat's ACL which i believe is still based on
JServ's.

thanks,

-jon

----------
From: Java Apache CVS Development <jon@clearink.com>
Reply-To: "Java-Apache Development" <jserv-dev@list.working-dogs.com>
Date: Sat, 17 Jun 2000 12:34:08 -0700 (PDT)
To: jserv-dev@list.working-dogs.com
Subject: CVS update: jserv/src/java/org/apache/java/lang
AdaptiveClassLoader.java

  User: jstoor  
  Date: 00/06/17 12:34:07

  Modified:    src/java/org/apache/java/lang AdaptiveClassLoader.java
  Log:
  this patch adds extra information to to the error message when a
  NoClassDefFoundError is thrown if it is not already present, and added
  an else clause to the method which I believe adds a bit of clarity
  (and removes the non-local goto of the early return).
  
  Daniel L. Rall <dlr@finemaltcoding.com>
  
  Revision  Changes    Path
  1.21      +29 -12
jserv/src/java/org/apache/java/lang/AdaptiveClassLoader.java
  
  Index: AdaptiveClassLoader.java
  ===================================================================
  RCS file: 
/products/cvs/master/jserv/src/java/org/apache/java/lang/AdaptiveClassLoader
.java,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- AdaptiveClassLoader.java    2000/03/12 05:34:42    1.20
  +++ AdaptiveClassLoader.java    2000/06/17 19:34:07    1.21
  @@ -115,7 +115,7 @@
    * @author Martin Pool
    * @author Jim Heintz
    * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
  - * @version $Revision: 1.20 $ $Date: 2000/03/12 05:34:42 $
  + * @version $Revision: 1.21 $ $Date: 2000/06/17 19:34:07 $
    * @see java.lang.ClassLoader
    */
   public class AdaptiveClassLoader extends ClassLoader {
  @@ -491,21 +491,38 @@
       private Class loadSystemClass(String name, boolean resolve)
           throws NoClassDefFoundError, ClassNotFoundException
       {
  -        if(myParentClassLoader != null)
  +        if (myParentClassLoader != null)
  +        {
               return myParentClassLoader.loadClass(name);
  -        Class c = findSystemClass(name);
  -        // Throws if not found.
  +        }
  +        else
  +        {
  +            try
  +            {
  +                // Throws if not found.
  +                Class c = findSystemClass(name);
  +            }
  +            catch (NoClassDefFoundError e)
  +            {
  +                StringBuffer msg = new StringBuffer(e.getMessage());
  +                if (msg.toString().lastIndexOf(name) == -1)
  +                {
  +                    msg.append(" could not find
'").append(name).append('\'');
  +                }
  +                throw new NoClassDefFoundError(msg.toString());
  +            }
   
  -        // Add cache entry
  -        ClassCacheEntry cacheEntry = new ClassCacheEntry();
  -        cacheEntry.origin = null;
  -        cacheEntry.loadedClass = c;
  -        cacheEntry.lastModified = Long.MAX_VALUE;
  -        cache.put(name, cacheEntry);
  +            // Add cache entry
  +            ClassCacheEntry cacheEntry = new ClassCacheEntry();
  +            cacheEntry.origin = null;
  +            cacheEntry.loadedClass = c;
  +            cacheEntry.lastModified = Long.MAX_VALUE;
  +            cache.put(name, cacheEntry);
   
  -        if (resolve) resolveClass(c);
  +            if (resolve) resolveClass(c);
   
  -        return c;
  +            return c;
  +        }
       }
   
       /**
  
  
  
  Index: AdaptiveClassLoader.java
  ===================================================================
  RCS file: 
/products/cvs/master/jserv/src/java/org/apache/java/lang/AdaptiveClassLoader
.java,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- AdaptiveClassLoader.java    2000/06/17 19:34:07    1.21
  +++ AdaptiveClassLoader.java    2000/06/17 19:38:41    1.22
  @@ -115,7 +115,7 @@
    * @author Martin Pool
    * @author Jim Heintz
    * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
  - * @version $Revision: 1.21 $ $Date: 2000/06/17 19:34:07 $
  + * @version $Revision: 1.22 $ $Date: 2000/06/17 19:38:41 $
    * @see java.lang.ClassLoader
    */
   public class AdaptiveClassLoader extends ClassLoader {
  @@ -497,10 +497,11 @@
           }
           else
           {
  +        Class c = null;
               try
               {
                   // Throws if not found.
  -                Class c = findSystemClass(name);
  +                c = findSystemClass(name);
               }
               catch (NoClassDefFoundError e)
               {
  
  



Mime
View raw message