View Javadoc

1   /***************************************************************************************
2    * Copyright (c) Jonas BonŽr, Alexandre Vasseur. All rights reserved.                 *
3    * http://aspectwerkz.codehaus.org                                                    *
4    * ---------------------------------------------------------------------------------- *
5    * The software in this package is published under the terms of the LGPL license      *
6    * a copy of which has been included with this distribution in the license.txt file.  *
7    **************************************************************************************/
8   package org.codehaus.aspectwerkz.compiler;
9   
10  import java.net.URL;
11  import java.net.URLClassLoader;
12  
13  /***
14   * VerifierClassLoader does not follow parent delegation model. <p/>It allow to run the -verify option of offline mode
15   * on aspectwerkz itself.
16   *
17   * @author <a href="mailto:alex@gnilux.com">Alexandre Vasseur </a>
18   */
19  public class VerifierClassLoader extends URLClassLoader {
20      public VerifierClassLoader(URL[] urls, ClassLoader parent) {
21          super(urls, parent);
22      }
23  
24      protected synchronized Class loadClass(String name, boolean resolve) throws ClassNotFoundException {
25          // First, check if the class has already been loaded
26          Class c = findLoadedClass(name);
27          if (c == null) {
28              try {
29                  // try to load the class localy
30                  c = findClass(name);
31              } catch (ClassNotFoundException e) {
32                  // delegate to parent
33                  c = getParent().loadClass(name);
34              }
35          }
36          if (resolve) {
37              resolveClass(c);
38          }
39          return c;
40      }
41  }