Sets the class loader for use by this ProcessingUnit.
504181
public void setClassLoader(final GroovyClassLoader loader) {
        // Classloaders should only be created inside a doPrivileged block in case
        // this method is invoked by code that does not have security permissions
        this.classLoader = loader != null ? loader : AccessController.doPrivileged(new PrivilegedAction<GroovyClassLoader>() {
            public GroovyClassLoader run() {
                ClassLoader parent = Thread.currentThread().getContextClassLoader();
                if (parent == null) parent = ProcessingUnit.class.getClassLoader();
                return new GroovyClassLoader(parent, configuration);
            }
        });
    }
507083
def _init_loaders(self) -> None:
        

        for loader in settings.I18N_TRANSLATION_LOADERS:
            loader_class = import_class(loader['loader'])
            instance = loader_class()
            instance.on_update(self.update)
            run(instance.load(**loader['params']))
424766
static void initialize() {
        if (INITIALIZED.getAndSet(true)) {
            throw new IllegalStateException("Already initialized");
        }
        // Set the default initializer if none has been provided yet.
        INITIALIZER.compareAndSet(null, new ServiceLoaderZoneRulesInitializer());
        INITIALIZER.get().initializeProviders();
    }
99410
public static void start(ClassLoader loader)
  {
    for (; loader != null; loader = loader.getParent()) {
      if (loader instanceof EnvironmentClassLoader) {
        ((EnvironmentClassLoader) loader).start();
        return;
      }
    }

    init(loader);

    for (int i = 0; i < _globalEnvironmentListeners.size(); i++) {
      EnvLoaderListener listener = _globalEnvironmentListeners.get(i);

      listener.environmentStart(null);
    }
  }
576228
@Deprecated
    protected void initialize() {
        // Cancel any running tasks
        Timer oldTimer = timer;
        timer = new Timer();
        if (oldTimer!=null) {
            oldTimer.cancel();
        }
        // (re)initialize
        LoaderConfigurator configurator = new LoaderConfigurator(this);
        defaultLoaderServiceFacade = new DefaultLoaderServiceFacade(timer, listener, resources);
        configurator.load();
    }
1179484
public static void popPreferredClassLoader() {
		final ClassLoader sysLoader = ClassLoaderFinder.class.getClassLoader();

		if ((dynamicLoader == null) || (dynamicLoader == sysLoader)) {
			dynamicLoader = null;
			final Thread[] threads = new Thread[Thread.activeCount()];
			Thread.enumerate(threads);
			for (final Thread t : threads) {
				if (t != null) {
					t.setContextClassLoader(sysLoader);
				}
			}
			return;
		}

		final ClassLoader parent = dynamicLoader.getParent();

		dynamicLoader = (parent == sysLoader) ? null : parent;

		final Thread[] threads = new Thread[Thread.activeCount()];
		Thread.enumerate(threads);
		for (final Thread t : threads) {
			if (t != null) {
				t.setContextClassLoader(parent);
			}
		}
	}
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());
         }
      }
   }
734783
public void resetThreadContextLoader() {
        if (LoaderUtils.isContextLoaderAvailable() && isContextLoaderSaved) {
            LoaderUtils.setContextClassLoader(savedContextLoader);
            savedContextLoader = null;
            isContextLoaderSaved = false;
        }
    }
1205273
public void classLoaderInit(DynamicClassLoader loader)
  {
    EnvLoaderListener listener = _listenerRef.get();
    
    if (listener != null)
      listener.classLoaderInit(loader);
  }
1361702
public function setLoader(Loader $loader)
    {
        $this->loader = $loader;
        $this->loader->setNamespace($this->getNamespace());
    }
875203
public static void preload(@NonNull ClassLoader classLoader) {
      Resource r = new ClasspathResource("META-INF/preload.classes", classLoader);
      if (r.exists()) {
         try {
            r.readLines().forEach(ReflectionUtils::getClassForNameQuietly);
         } catch (IOException e) {
            e.printStackTrace();
         }
      }
   }
253616
private static void init(ClassLoader classLoader, SecurityManager securityManager, Set<String> securedClasses) {
		if (classLoader == null)
			throw new IllegalArgumentException("A class loader must be provided");
		
		if (securityManager == null)
			throw new IllegalArgumentException("A security manager must be provided");
		
		if (securedClasses == null)
			throw new IllegalArgumentException("Secured classes cannot be null");
		
		Security.securityManager = securityManager;

		ClassPool cp = ClassPool.getDefault();

		for (String securedClass : securedClasses) {
			secure(classLoader, cp, securedClass);
		}
	}
334933
public void setThreadContextLoader() {
        if (isContextLoaderSaved) {
            throw new BuildException("Context loader has not been reset");
        }
        if (LoaderUtils.isContextLoaderAvailable()) {
            savedContextLoader = LoaderUtils.getContextClassLoader();
            ClassLoader loader = this;
            if (project != null && "only".equals(project.getProperty("build.sysclasspath"))) {
                loader = this.getClass().getClassLoader();
            }
            LoaderUtils.setContextClassLoader(loader);
            isContextLoaderSaved = true;
        }
    }
214996
protected void processClass (File source)
    {
        CtClass clazz;
        InputStream in = null;
        try {
            clazz = _pool.makeClass(in = new BufferedInputStream(new FileInputStream(source)));
        } catch (IOException ioe) {
            System.err.println("Failed to load " + source + ": " + ioe);
            return;
        } finally {
            StreamUtil.close(in);
        }

        try {
            if (clazz.subtypeOf(_streamable)) {
                processStreamable(source, clazz);
            }
        } catch (NotFoundException nfe) {
            System.err.println("Error processing class [class=" + clazz.getName() +
                               ", error=" + nfe + "].");
        }
    }
27999
public final void addSubLoader(AbstractClassLoader loader) {
		if (subLoaders == null) subLoaders = new ArrayList<>();
		subLoaders.add(loader);
	}
1074717
public void setResourceLoader(ResourceLoader resourceLoader) {
		this.resourceLoader = resourceLoader;
		this.xmlReader.setResourceLoader(resourceLoader);
		this.scanner.setResourceLoader(resourceLoader);
	}
1309304
public void setClassLoaderProvider(String id, ClassLoaderProvider classLoaderProvider) {
        if (classLoaderProvider != null) {
            classLoaderProviderMap.put(id, classLoaderProvider);
        } else {
            classLoaderProviderMap.remove(id);
        }
    }