Load a class using this class loader

@param name the classname to load
@param resolve if true, resolve the class

@return the loaded classes
171766
@Override
  public Class<?> loadClassImpl(String name, boolean resolve)
    throws ClassNotFoundException
  {
    // The JVM has already cached the classes, so we don't need to
    Class<?> cl = findLoadedClass(name);

    if (cl != null) {
      if (resolve)
        resolveClass(cl);
      return cl;
    }
    // System.out.println("ROOT: " + name);
    if (_classNotFoundCache.get(name) != null) {
      return null;
    }
    
    try {
      cl = super.loadClassImpl(name, resolve);
    } catch (ClassNotFoundException e) {
      _classNotFoundCache.put(name, name);
      
      throw e;
    }
    
    if (cl == null) {
      _classNotFoundCache.put(name, name);
    }
    
    return cl;
  }
875771
public NonDelayedClassInfo resolveClassInfo(String name) {
        NonDelayedClassInfo cachedClassInfo = basicGetClassInfo(name);
        if (cachedClassInfo != null) {
            if (tc.isDebugEnabled()) {
                Tr.debug(tc, MessageFormat.format("[ {0} ] ENTER / RETURN [ {1} ] - cached",
                                                  new Object[] { getHashText(), cachedClassInfo.getHashText() }));
            }
            return cachedClassInfo;
        }

        String useHashText = (tc.isDebugEnabled() ? getHashText() : null);

        NonDelayedClassInfo javaClassInfo = basicGetJavaClassInfo(name);

        if (javaClassInfo != null) {
            if (useHashText != null) {
                Tr.debug(tc, MessageFormat.format("[ {0} ] RETURN [ {1} ] java class",
                                                  new Object[] { useHashText, javaClassInfo.getHashText() }));
            }
            return javaClassInfo;
        }

        NonDelayedClassInfo annotatedClassInfo = basicGetAnnotatedClassInfo(name);

        if (annotatedClassInfo != null) {
            if (useHashText != null) {
                Tr.debug(tc, MessageFormat.format("[ {0} ] RETURN [ {1} ] annotated class",
                                                  new Object[] { useHashText, annotatedClassInfo.getHashText() }));
            }
            return annotatedClassInfo;
        }

        if (useHashText != null) {
            Tr.debug(tc, MessageFormat.format("ENTRY [ {0} ] Class [ {1} ] ",
                                              new Object[] { useHashText, name }));
        }

        try {
            scanClass(name); // This has side effects on the ClassInfoCache!
            // throws InfoStoreException

        } catch (InfoStoreException e) {
            Tr.warning(tc, "ANNO_CLASSINFO_SCAN_EXCEPTION", getHashText(), name, e.getMessage(),
                       e.getCause() == null ? e.getMessage() : e.getCause().getMessage()); // CWWKC0022W

            if (useHashText != null) {
                Tr.debug(tc, MessageFormat.format("[ {0} ] RETURN [ null ]; class scan failed with an exception",
                                                  new Object[] { useHashText, name }));
            }
            return null;
        }

        cachedClassInfo = basicGetClassInfo(name);

        if (cachedClassInfo != null) {
            if (tc.isDebugEnabled()) {
                Tr.debug(tc, MessageFormat.format("[ {0} ] ENTER / RETURN [ {1} ] - newly cached",
                                                  new Object[] { getHashText(), cachedClassInfo.getHashText() }));
            }
            return cachedClassInfo;
        }

        javaClassInfo = basicGetJavaClassInfo(name);

        if (javaClassInfo != null) {
            if (useHashText != null) {
                Tr.debug(tc, MessageFormat.format("[ {0} ] RETURN [ {1} ] newly added java class",
                                                  new Object[] { useHashText, javaClassInfo.getHashText() }));
            }
            return javaClassInfo;
        }

        annotatedClassInfo = basicGetAnnotatedClassInfo(name);

        if (annotatedClassInfo != null) {
            if (useHashText != null) {
                Tr.debug(tc, MessageFormat.format("[ {0} ] RETURN [ {1} ] new added annotated class",
                                                  new Object[] { useHashText, annotatedClassInfo.getHashText() }));
            }
            return annotatedClassInfo;
        }

        // START: TFB: Defect 59284: Don't throw an exception for a failed load.

        // A warning is logged by DelayedClassInfo.getClassInfo.
        //
        // scanLogger.logp(Level.WARNING, CLASS_NAME, methodName,
        //                 "[ {0} ] Internal error resolving [ {1} ]",
        //                 new Object[] { getHashText(), name });

        if (useHashText != null) {
            Tr.debug(tc, MessageFormat.format("[ {0} ] RETURN [ null ] for class which was not found",
                                              new Object[] { useHashText, name }));
        }
        return null;

        // String eMsg = "[ " + getHashText() + " ] Internal error resolving [ " + name + " ]";
        // RuntimeException e = new RuntimeException(eMsg);
        //
        // scanLogger.log(Level.WARNING, eMsg, e);
        // throw e;

        // END: TFB: Defect 59284
    }
939405
@Override
  public Class<?> loadClassImpl(String name, boolean resolve)
    throws ClassNotFoundException
  {
    // The JVM has already cached the classes, so we don't need to
    Class<?> cl = findLoadedClass(name);

    if (cl != null) {
      if (resolve) {
        resolveClass(cl);
      }
      
      return cl;
    }

    String className = name;
    
    if (_hasBootClassPath) {
      className = name.replace('.', '/') + ".class";

      if (findPath(className) == null) {
        return null;
      }
    }

    try {
      return super.loadClassImpl(name, resolve);
    } catch (Error e) {
      className = name.replace('.', '/') + ".class";
      
      if (findPath(className) != null) {
        String msg =  (e + "\n  while loading " + name + " in " + this
                       + "\n  which exists in " + findPath(className)
                       + "\n  check for missing dependencies");
        
        log().warning(msg);
      }
      
      throw e;
    } catch (ClassNotFoundException e) {
      className = name.replace('.', '/') + ".class";
      
      if (findPath(className) != null) {
        String msg =  (e + "\n  " + name + " in " + this
            + "\n  exists in " + findPath(className)
            + "\n  check for missing dependencies");
        
        log().fine(msg);
        
        throw new ClassNotFoundException(e.getMessage() + "\n" + msg, e);
      }
      
      throw e;
    }
  }
1332552
@Override
	protected Class<?> findClass(final String name) throws ClassNotFoundException {
		log.trace("findClass:" + name);
		Class<?> clazz = findLoadedClass(name);
		if (clazz != null) {
			return clazz;
		}
		return super.findClass(name);
	}
1188053
public static Class<?> loadClass(String classname, DataFormat<?> dataFormat) {

    // first try context classoader
    ClassLoader cl = Thread.currentThread().getContextClassLoader();
    if(cl != null) {
      LOG.tryLoadingClass(classname, cl);
      try {
        return cl.loadClass(classname);
      }
      catch(Exception e) {
        // ignore
      }
    }

    // else try the classloader which loaded the dataformat
    cl = dataFormat.getClass().getClassLoader();
    try {
      LOG.tryLoadingClass(classname, cl);
      return cl.loadClass(classname);
    }
    catch (ClassNotFoundException e) {
      throw LOG.classNotFound(classname, e);
    }

  }
140714
@SuppressWarnings("unchecked")
    public static <T> Class<T> loadClass(String className) throws ClassNotFoundException {
        return (Class<T>) getClassLoader().loadClass(className);
    }
289125
protected Class<?> resolveClass(String name) throws ClassNotFoundException {
        // ClassLoader.loadClass is not guaranteed to support array classes:
        // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4976356
        // ...so we must handle them ourselves.
        if (name.length() > 0 && name.charAt(0) == '[') {
            int numComponents = 0;
            do {
                numComponents++;
                if (numComponents == name.length()) {
                    throw new ClassNotFoundException(name);
                }
            } while (name.charAt(numComponents) == '[');

            if (name.charAt(numComponents) != 'L') {
                // Primitive array class expected.
                return resolveClassWithCL(name);
            }

            if (name.charAt(name.length() - 1) != ';') {
                // Unexpected erroneous class name.
                throw new ClassNotFoundException(name);
            }

            if (name.regionMatches(numComponents + 1, "java.", 0, 5)) {
                // Path for "java." classes.
                return resolveClassWithCL(name);
            }

            // Load the actual class, and then use that class' loader to load
            // the desired array class.
            String className = name.substring(numComponents + 1, name.length() - 1);
            Class<?> klass = loadClass(className);
            return Class.forName(name, false, getClassLoader(klass));
        }

        if (name.startsWith("java.")) {
            // Path for "java." classes.
            return resolveClassWithCL(name);
        }

        return loadClass(name);
    }
146946
@Override
  public Class<?> classForName(final String name) throws ClassNotFoundException {
    return ReflectionUtilities.classForName(name, loader);
  }
1306250
public Class<?> internalLoadClass(String name, boolean resolve) throws ClassNotFoundException {
        if (CACHE_NON_EXISTING_CLASSES && nonExistingClasses.contains(name)) {
            throw dummyCFNE;
        }

        if (droolsClassLoader != null) {
            try {
                return Class.forName(name, resolve, droolsClassLoader);
            } catch (ClassNotFoundException e) { }
        }
        try {
            return super.loadClass(name, resolve);
        } catch (ClassNotFoundException e) {
            return Class.forName(name, resolve, getParent());
        }
    }
1219461
@Override
  protected Class<?> resolveClass(ObjectStreamClass desc) throws IOException,
      ClassNotFoundException {
    return Class.forName(desc.getName(), true, loader);
  }
873638
private Class<?> loadClass(final String classname) throws PluginException {
        if (null == classname) {
            throw new IllegalArgumentException("A null java class name was specified.");
        }
        if (null != classCache.get(classname)) {
            return classCache.get(classname);
        }
        CachedJar cachedJar1 = getCachedJar();

        debug("loadClass! " + classname + ": " + cachedJar1.getCachedJar());
        final Class<?> cls;
        final URLClassLoader urlClassLoader = cachedJar1.getClassLoader();
        try {
            cls = Class.forName(classname, true, urlClassLoader);
            classCache.put(classname, cls);
        } catch (ClassNotFoundException e) {
            throw new PluginException("Class not found: " + classname, e);
        } catch (Throwable t) {
            throw new PluginException("Error loading class: " + classname, t);
        }
        return cls;
    }
909347
public static <T> Class<T> loadClass(String className, ResourceLoader resourceLoader) {
        try {
            return cast(resourceLoader.classForName(className));
        } catch (ResourceLoadingException e) {
            return null;
        } catch (SecurityException e) {
            return null;
        }
    }
1050886
public static Class get(String clazzname, ClassLoader loader) throws ClassNotFoundException {
        return Util.loadClass(clazzname, loader != null? loader : ClassConfigurator.class.getClassLoader());
    }
791929
@Override
	protected Class<?> loadClass(String className, boolean resolve) throws ClassNotFoundException {
		Class<?> clazz= null;
		try {
			clazz = findClass(className);//查找已经加载过的类或者待加载的类
		} catch (Exception e) {
		}
		if (clazz == null) {// 系统类加载
			try {
				clazz = findSystemClass(className);
			} catch (ClassNotFoundException e) {
			}
		}
		if (clazz == null) {// 上层加载器加载
			ClassLoader parent=getParent();
			if(parent!=null)
			{
				try {
					clazz = parent.loadClass(className);
				} catch (Exception e) {
				}
			}
		}
		// 查找当前类加载中已加载的
		if (clazz == null) {
			throw new ClassNotFoundException("className:"+className+",resolve:"+resolve);
		}
		String classLoader = "" + clazz.getClassLoader();
		if (resolve) {// 解析类结构
			resolveClass(clazz);
		}
		log.trace("loadClass " + (clazz == null) + ":" + className + ",resolve=" + resolve + ",Clazz=" + clazz+ ",ClassLoader=" + classLoader);
		return clazz;
	}
1142344
public static Class<? extends WebPage> loadClass(String className) throws ClassNotFoundException {
		return Class.forName(className).asSubclass(WebPage.class);
	}
1174805
public static Class loadClass(Class loadClass,String name)
        throws ClassNotFoundException
    {
        ClassNotFoundException cnfe=null;
        ClassLoader loader=Thread.currentThread().getContextClassLoader();
        if (loader!=null)
        {
            try
            {
               return loader.loadClass(name);
            }
            catch (ClassNotFoundException e)
            {
               cnfe=e;
            }
        }

        loader=loadClass.getClassLoader();
        if (loader!=null)
        {
            try
            {
               return loader.loadClass(name);
            }
            catch (ClassNotFoundException e)
            {
               if(cnfe==null)cnfe=e;
            }
        }


       try
       {
            return Class.forName(name);
       }
       catch (ClassNotFoundException e)
       {
            if(cnfe==null)cnfe=e;
	    throw cnfe;
       }

    }
1341547
private static Class<?> loadClass(String className) {
        try {
            return Class.forName(className, false, getClassLoader());
        } catch (ClassNotFoundException e) {
            throw new RuntimeException(e);
        }
    }