Used for isolated resource seaching.
@return the root classloader of AntClassLoader.
437448
private ClassLoader getRootLoader() {
        ClassLoader ret = getClass().getClassLoader();
        while (ret != null && ret.getParent() != null) {
            ret = ret.getParent();
        }
        return ret;
    }
814987
protected ClassLoader getClassLoader() {
        ClassLoader classLoader = null;
        try {
            classLoader = Thread.currentThread().getContextClassLoader();
        } catch (Throwable ex) {
            // Cannot access thread context ClassLoader - falling back...
        }
        return (classLoader != null ? classLoader : getClass().getClassLoader());
    }
918868
@NotNull
    public final ArtifactFactory<?> getFactory() {
        if (factory == null) {
            if (factoryClassName == null) {
                throw new IllegalStateException("Factory class name was not set: " + artifact);
            }
            if (context == null) {
                throw new IllegalStateException("Context class loader was not set: " + artifact);
            }
            final Object obj = Utils4J.createInstance(factoryClassName, context.getClassLoader());
            if (!ArtifactFactory.class.isAssignableFrom(obj.getClass())) {
                throw new IllegalStateException(
                        "Expected an object of type '" + ArtifactFactory.class.getName() + "', but was: " + obj.getClass());
            }
            factory = (ArtifactFactory<?>) obj;
            factory.init(this);
        }
        return factory;
    }
41656
@Override
    public ClassLoader getClassLoader() {
        ClassLoader classLoader = this.initialClass.getClassLoader();
        if (classLoader == null) {
            classLoader = application.getClassLoader();
        }
        return classLoader;
    }
330932
public static ClassLoader getThreadContextClassLoader()
    {
        Thread thread=Thread.currentThread();
        ClassLoader classLoader=thread.getContextClassLoader();
        
        return classLoader;
    }
129826
public ClassLoader buildClassLoader(ClassLoader serviceLoader)
  {
    synchronized (_loaderMap) {
      SoftReference<ClassLoader> extLoaderRef = _loaderMap.get(serviceLoader);
      
      if (extLoaderRef != null) {
        ClassLoader extLoader = extLoaderRef.get();
        
        if (extLoader != null) {
          return extLoader;
        }
      }
    }
    
    String parentId = EnvLoader.getEnvironmentName(serviceLoader);
    
    String id = _id + "!" + parentId;
    
    //DynamicClassLoader extLoader = new PodExtClassLoader(serviceLoader, id);
    DynamicClassLoader extLoader = null;

    /*
    LibraryLoader libLoader
      = new LibraryLoader(extLoader, getRootDirectory().lookup("lib"));
    libLoader.init();
    
    CompilingLoader compLoader
      = new CompilingLoader(extLoader, getRootDirectory().lookup("classes"));
    compLoader.init();
    
    synchronized (_loaderMap) {
      SoftReference<ClassLoader> extLoaderRef = _loaderMap.get(serviceLoader);
      
      if (extLoaderRef != null) {
        ClassLoader extLoaderOld = extLoaderRef.get();
        
        if (extLoaderOld != null) {
          return extLoaderOld;
        }
      }
      
      _loaderMap.put(serviceLoader, new SoftReference<>(extLoader));
    }
    */
    
    return extLoader;
  }
751391
public Weld setClassLoader(ClassLoader classLoader) {
        Preconditions.checkNotNull(classLoader);
        resourceLoader = new ClassLoaderResourceLoader(classLoader);
        return this;
    }
471391
public Class getRootDeclarationClass() {
        ConfigPath res = this;
        while (res.getRoot() != null) {
            res = res.getRoot();
        }
        return res.getDeclarationClass();
    }
513044
private static ClassHierarchy loadClassHierarchy() {
    // TODO[JIRA REEF-400] The file should be created by AvroClassHierarchySerializer
    try (final InputStream chin = new FileInputStream(HelloCLR.CLASS_HIERARCHY_FILENAME)) {
      // TODO[JIRA REEF-400] Use AvroClassHierarchySerializer instead
      final ClassHierarchyProto.Node root = ClassHierarchyProto.Node.parseFrom(chin); // A
      final ClassHierarchy ch = new ProtocolBufferClassHierarchy(root);
      return ch;
    } catch (final IOException e) {
      final String message = "Unable to load class hierarchy.";
      LOG.log(Level.SEVERE, message, e);
      throw new RuntimeException(message, e);
    }
  }
224382
public static final CClassLoader getLoader(final String fpath) {
		String path = fpath;
		CClassLoader currentLoader = CClassLoader.rootLoader;

		if (path == null) {
			return CClassLoader.getRootLoader();
		}

		if (path.startsWith(CClassLoader.ROOT_LOADER)) {
			path = path.substring(10);
		}

		final StringTokenizer tokenizer = new StringTokenizer(path, "/", false);

		while (tokenizer.hasMoreTokens()) {
			final String name = tokenizer.nextToken();
			currentLoader = currentLoader.getLoaderByName(name);
		}

		return currentLoader;
	}
1030648
private ClassLoader getCombinedClassLoader(ClassRealmManager manager) {

        List<URL> urlList = new ArrayList<URL>();

        // add thread classpath
        ClassLoader threadCL = SecurityActions.getThreadContextClassLoader();
        if (threadCL instanceof URLClassLoader) {
            urlList.addAll(Arrays.asList(((URLClassLoader) threadCL).getURLs()));
        }

        // add maven core libraries
        ClassRealm core = manager.getCoreRealm();
        if (core != null) {
            urlList.addAll(Arrays.asList(core.getURLs()));
        }

        ClassRealm mavenApi = manager.getMavenApiRealm();
        if (mavenApi != null) {
            urlList.addAll(Arrays.asList(mavenApi.getURLs()));
        }

        // we need to keep threadCL as parent, otherwise we'll get ClassCastException in runtime
        URLClassLoader cl = new URLClassLoader(urlList.toArray(new URL[0]), threadCL);

        // for (URL u : cl.getURLs()) {
        // System.out.println("CLR: " + u);
        // }

        return cl;
    }
296571
public final UserManagedCacheBuilder<K, V, T> withClassLoader(ClassLoader classLoader) {
    if (classLoader == null) {
      throw new NullPointerException("Null classloader");
    }
    UserManagedCacheBuilder<K, V, T> otherBuilder = new UserManagedCacheBuilder<>(this);
    otherBuilder.classLoader = classLoader;
    return otherBuilder;
  }
591763
@Override
    public ClassLoader getThrowawayClassLoader() {
        ClassLoader newParent = getThrowawayVersion(getParent());
        ClassLoader[] newFollowOns = new ClassLoader[followOnClassLoaders.size()];
        for (int i = 0; i < newFollowOns.length; i++) {
            newFollowOns[i] = getThrowawayVersion(followOnClassLoaders.get(i));
        }
        return new UnifiedClassLoader(newParent, newFollowOns);
    }
674593
static ClassLoader findClassLoader()
        throws ConfigurationError
    { 
        SecuritySupport ss = SecuritySupport.getInstance();

        // Figure out which ClassLoader to use for loading the provider
        // class.  If there is a Context ClassLoader then use it.
        ClassLoader context = ss.getContextClassLoader();
        ClassLoader system = ss.getSystemClassLoader();

        ClassLoader chain = system;
        while (true) {
            if (context == chain) {
                // Assert: we are on JDK 1.1 or we have no Context ClassLoader
                // or any Context ClassLoader in chain of system classloader
                // (including extension ClassLoader) so extend to widest
                // ClassLoader (always look in system ClassLoader if Xalan
                // is in boot/extension/system classpath and in current
                // ClassLoader otherwise); normal classloaders delegate
                // back to system ClassLoader first so this widening doesn't
                // change the fact that context ClassLoader will be consulted
                ClassLoader current = ObjectFactory.class.getClassLoader();

                chain = system;
                while (true) {
                    if (current == chain) {
                        // Assert: Current ClassLoader in chain of
                        // boot/extension/system ClassLoaders
                        return system;
                    }
                    if (chain == null) {
                        break;
                    }
                    chain = ss.getParentClassLoader(chain);
                }

                // Assert: Current ClassLoader not in chain of
                // boot/extension/system ClassLoaders
                return current;
            }

            if (chain == null) {
                // boot ClassLoader reached
                break;
            }

            // Check for any extension ClassLoaders in chain up to
            // boot ClassLoader
            chain = ss.getParentClassLoader(chain);
        };

        // Assert: Context ClassLoader not in chain of
        // boot/extension/system ClassLoaders
        return context;
    }
580697
public static PropertiesLoader getPropertiesLoader() {
		synchronized (PropertiesLoader.class) {
			final ClassLoader classLoader = ConfigurableClassLoader.INSTANCE.getClassLoader();
			PropertiesLoader loader = clMap.get(classLoader);
			if (loader == null) {
				try {
					loader = new PropertiesLoader(MASTER_PLUGIN_FILE, EXTRA_PLUGIN_FILE);
					clMap.put(classLoader, loader);
				} catch (final IOException ex) {
					throw new RuntimeException(ex);
				}
			}
			return loader;
		}
	}
642756
public static ClassLoader getParentClassLoader() {
		logger.debug("getParentClassLoader() invoked, web start mode: {}", IS_WEB_START);
		if (IS_WEB_START) {
			return Thread.currentThread().getContextClassLoader();
		} else {
			return ClassLoaderUtils.class.getClassLoader();
		}
	}
670322
protected static ClassLoader getContextClassLoader()
    {
        if (System.getSecurityManager() != null)
        {
            try
            {
                Object cl = AccessController.doPrivileged(new PrivilegedExceptionAction()
                {
                            public Object run() throws PrivilegedActionException
                            {
                                return Thread.currentThread().getContextClassLoader();
                            }
                });
                return (ClassLoader) cl;
            }
            catch (PrivilegedActionException pae)
            {
                throw new FacesException(pae);
            }
        }
        else
        {
            return Thread.currentThread().getContextClassLoader();
        }
    }