Set explicit class loader to use when searching for Java classes.

@see #getApplicationClassLoader()
183795
public final void initApplicationClassLoader(ClassLoader loader)
    {
        if (loader == null)
            throw new IllegalArgumentException("loader is null");
        if (!Kit.testIfCanLoadRhinoClasses(loader))
            throw new IllegalArgumentException(
                "Loader can not resolve Rhino classes");

        if (this.applicationClassLoader != null)
            throw new IllegalStateException(
                "applicationClassLoader can only be set once");
        checkNotSealed();

        this.applicationClassLoader = loader;
    }
310764
public static ClassLoader getContextClassLoader() {
        ClassLoader loader = null;
        try {
            loader = Thread.currentThread().getContextClassLoader();
        } catch (Throwable e) {
        }
        if (loader == null) {
            loader = ClassUtils.class.getClassLoader();
        }
        return loader;
    }
294015
public static ClassLoader getDefaultClassLoader() {
        ClassLoader loader = Thread.currentThread().getContextClassLoader();
        if (loader == null) {
            loader = ClassUtils.class.getClassLoader();
            if (loader == null) {
                loader = ClassLoader.getSystemClassLoader();
            }
        }
        return loader;
    }
833974
public static void setPreferredClassLoader(ClassLoader classLoader) {
		if (classLoader != dynamicLoader) {
			dynamicLoader = classLoader;
			final Thread[] threads = new Thread[Thread.activeCount()];
			Thread.enumerate(threads);
			for (final Thread t : threads) {
				if (t != null) {
					t.setContextClassLoader(classLoader);
				}
			}
		}
	}
799286
@SuppressWarnings("rawtypes")
    public static Class loadClass(String name) throws ClassNotFoundException {
        ClassLoader loader = Thread.currentThread().getContextClassLoader();
        return (loader == null) ? Class.forName(name) : loader.loadClass(name);
    }
716468
public static ApplicationClassLoader getJarApplicationClassLoader(String jarFilePath) {
        ApplicationClassLoader jarApplicationClassLoader = jarApplicationClassLoaderCache.get(jarFilePath);
        if (jarApplicationClassLoader != null) {
            return jarApplicationClassLoader;
        }
        synchronized (jarApplicationClassLoaderCache) {
            jarApplicationClassLoader = jarApplicationClassLoaderCache.get(jarFilePath);
            if (jarApplicationClassLoader != null) {
                return jarApplicationClassLoader;
            }
            jarApplicationClassLoader = new ApplicationClassLoader(nodeApplicationClassLoader, false);
            jarApplicationClassLoader.addJarFiles(jarFilePath);
            jarApplicationClassLoaderCache.put(jarFilePath, jarApplicationClassLoader);
            return jarApplicationClassLoader;
        }
    }
1066460
private static URLClassLoader getCurrentClassLoader() {
		synchronized (Boot.class) {
			if (dynamicClassLoader == null) {
				final ClassLoader cl = ClassLoader.getSystemClassLoader();
				if (cl instanceof URLClassLoader) {
					dynamicClassLoader = (URLClassLoader) cl;
				} else {
					dynamicClassLoader = URLClassLoader.newInstance(new URL[0], cl);
				}
			}
			return dynamicClassLoader;
		}
	}
1249529
static ClassLoader setContextClassLoader(final ClassLoader cl)
   {
      if (System.getSecurityManager() == null)
      {
         ClassLoader result = Thread.currentThread().getContextClassLoader();
         if (cl != null)
            Thread.currentThread().setContextClassLoader(cl);
         return result;
      }
      else
      {
         try
         {
            return AccessController.doPrivileged(new PrivilegedExceptionAction<ClassLoader>() {
               public ClassLoader run() throws Exception
               {
                  try
                  {
                     ClassLoader result = Thread.currentThread().getContextClassLoader();
                     if (cl != null)
                        Thread.currentThread().setContextClassLoader(cl);
                     return result;
                  }
                  catch (Exception e)
                  {
                     throw e;
                  }
                  catch (Error e)
                  {
                     throw e;
                  }
                  catch (Throwable e)
                  {
                     throw new RuntimeException("Error setting context classloader", e);
                  }
               }
            });
         }
         catch (PrivilegedActionException e)
         {
            throw new RuntimeException("Error running privileged action", e.getCause());
         }
      }
   }
1044245
@Override
  public ClassLoader getClassLoader() {
    URL[] urlsForClassLoader = new URL[urls.size()];
    urls.toArray(urlsForClassLoader);

    URLClassLoader classLoader = new URLClassLoader(urlsForClassLoader);
    Thread.currentThread().setContextClassLoader(classLoader);

    return classLoader;
  }
127798
@Override
    public Class<?> loadClass(String classname) throws ClassNotFoundException {
        return getClass().getClassLoader().loadClass(classname);
    }
469830
public static ClassLoader getClassLoader()
    {
        try
        {
            ClassLoader cl = Thread.currentThread().getContextClassLoader();
            if ( cl != null ) return cl;
        }
        catch ( SecurityException e )
        {
            if ( _log.isDebugEnabled() )
            {
                _log.debug( "Could not get thread context classloader.", e );
            }
        }
        
        if ( _log.isTraceEnabled() )
        {
            _log.trace( "Can't use thread context classloader; using classloader for " + DiscoveryUtils.class.getName() );
        }
        
        return DiscoveryUtils.class.getClassLoader();
    }
437448
private ClassLoader getRootLoader() {
        ClassLoader ret = getClass().getClassLoader();
        while (ret != null && ret.getParent() != null) {
            ret = ret.getParent();
        }
        return ret;
    }
1255961
@Override
    protected Class<?> loadClass(String name, boolean resolve)
            throws ClassNotFoundException {
        synchronized (LaunchedURLClassLoader.LOCK_PROVIDER.getLock(this, name)) {
            Class<?> loadedClass = findLoadedClass(name);
            if (loadedClass == null) {
                Handler.setUseFastConnectionExceptions(true);
                try {
                    loadedClass = doLoadClass(name);
                } finally {
                    Handler.setUseFastConnectionExceptions(false);
                }
            }
            if (resolve) {
                resolveClass(loadedClass);
            }
            return loadedClass;
        }
    }
1205273
public void classLoaderInit(DynamicClassLoader loader)
  {
    EnvLoaderListener listener = _listenerRef.get();
    
    if (listener != null)
      listener.classLoaderInit(loader);
  }
462197
@Override
    public void setClassPath( URL [] cp ) {
        baseClassPath.setPath( cp );
        initBaseLoader();
        loaderMap = new HashMap();
        classLoaderChanged();
    }
718587
protected void initialiseApplicationContext() {
        if (context != null) {
            return;
        }

        context = createApplicationContext(parent);

        if (parent != null && classLoader == null) {
            trySettingClassLoaderOnContextIfFoundInParent(parent);
        }
        else if (classLoader != null) {
            setClassLoaderOnContext(classLoader);
        }

        Assert.notNull(context, "ApplicationContext cannot be null");
    }
8430
@Override
  public void setContextLoader(ClassLoader loader)
  {
    if (loader != null)
      _loaderRef = new WeakReference<ClassLoader>(loader);
    else
      _loaderRef = null;
  }