Get current thread context ClassLoader

@return return ClassLoader
160284
public static ClassLoader getDefault() {
        ClassLoader loader = null;
        try {
            loader = Thread.currentThread().getContextClassLoader();
        } catch (Exception ignored) {
        }
        if (loader == null) {
            loader = Environment.class.getClassLoader();
            if (loader == null) {
                try {
                    // getClassLoader() returning null indicates the bootstrap ClassLoader
                    loader = ClassLoader.getSystemClassLoader();
                } catch (Exception e) {
                    // Cannot access system ClassLoader - oh well, maybe the caller can live with null...
                }
            }
        }
        return loader;
    }
952226
public static ClassLoader getClassLoader(final Class<?> clazz) {
        // Context class loader can be null
        final ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
        if (contextClassLoader != null) {
            return contextClassLoader;
        }
        if (clazz != null) {
            // The class loader for a specific class can also be null
            final ClassLoader clazzClassLoader = clazz.getClassLoader();
            if (clazzClassLoader != null) {
                return clazzClassLoader;
            }
        }
        // The only class loader we can rely on for not being null is the system
        // one
        return ClassLoader.getSystemClassLoader();
    }
582887
public ThreadContext getThreadContext() {
        if (useInheritableThreadLocal && !SSLConfigManager.getInstance().isServerProcess()) {
            ThreadContext context = inheritableThreadLocStorage.get();

            if (context == null) {
                context = new ThreadContext();
                inheritableThreadLocStorage.set(context);
            }
            return context;
        }
        ThreadContext context = threadLocStorage.get();

        if (context == null) {
            context = new ThreadContext();
            threadLocStorage.set(context);
        }

        return context;
    }
775412
public static ClassLoader getClassLoaderContextAt(int i) {
		Class[] classes = MANAGER.getClassContext();
		if (classes != null && classes.length > i) {
			return classes[i].getClassLoader();
		}
		return null;
	}
780963
public KryoInstantiator setThreadContextClassLoader() {
    return new KryoInstantiator() {
      public Kryo newKryo() {
        Kryo k = KryoInstantiator.this.newKryo();
        k.setClassLoader(Thread.currentThread().getContextClassLoader());
        return k;
      }
    };
  }
162813
public static ThreadManager getInstance() {
        if (thisClass == null) {
            thisClass = new ThreadManager();

            String useInheritableThreadLocalString = SSLConfigManager.getInstance().getGlobalProperty(Constants.SSLPROP_USE_INHERITABLE_THREAD_LOCAL);
            if (useInheritableThreadLocalString != null && (useInheritableThreadLocalString.equalsIgnoreCase("true") || useInheritableThreadLocalString.equalsIgnoreCase("yes"))) {
                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                    Tr.debug(tc, "useInheritableThreadLocal is enabled.");
                useInheritableThreadLocal = true;
            }
        }

        return thisClass;
    }
633999
private static ClassLoader getPlatformClassLoader() {
        if (JavaInfo.majorVersion() >= 9) {
            return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
                @Override
                public ClassLoader run() {
                    ClassLoader pcl = null;
                    try {
                        Method getPlatformClassLoader = ClassLoader.class.getMethod("getPlatformClassLoader");
                        pcl = (ClassLoader) getPlatformClassLoader.invoke(null);
                    } catch (Throwable t) {
                        // Log an FFDC.
                    }
                    return pcl;
                }
            });
        }
        return null;
    }
632140
protected function getContextObject()
    {
        if ($this->contextObject === null) {
            $this->contextObject = $this->loadContextObject();
        }

        return $this->contextObject;
    }
277699
private static ClassLoader[] getClassLoaders(ClassLoader classLoader) {
		return new ClassLoader[] { classLoader, Thread.currentThread().getContextClassLoader(), ClassLoaderUtils.class.getClassLoader(),
				systemClassLoader };
	}
1042379
public static ServiceManagerProvider current()
  {
    ServiceManagerProvider systemProvider = _systemProvider;
    
    if (systemProvider != null) {
      return systemProvider;
    }
    
    Thread thread = Thread.currentThread();
    ClassLoader loader = thread.getContextClassLoader();
    
    return getProvider(loader);
  }
134608
public static ClassLoader getParaClassLoader() {
		if (paraClassLoader == null) {
			try {
				ClassLoader currentClassLoader = Thread.currentThread().getContextClassLoader();
				List<URL> jars = new ArrayList<>();
				File lib = new File(Config.getConfigParam("plugin_folder", "lib/"));
				if (lib.exists() && lib.isDirectory()) {
					for (File file : FileUtils.listFiles(lib, new String[]{"jar"}, false)) {
						jars.add(file.toURI().toURL());
					}
				}
				paraClassLoader = new URLClassLoader(jars.toArray(new URL[0]), currentClassLoader);
				// Thread.currentThread().setContextClassLoader(paraClassLoader);
			} catch (Exception e) {
				logger.error(null, e);
			}
		}
		return paraClassLoader;
	}
1264393
public static void findClassLoaderOrder(final ClassLoader classLoader,
            final ClassLoaderOrder classLoaderOrder) {
        // The Restart classloader is a parent-last classloader, so need to delegate to the context
        // classloader(s) before the parent.
        classLoaderOrder.delegateTo(Thread.currentThread().getContextClassLoader(), /* isParent = */ false);
        classLoaderOrder.delegateTo(ClassGraph.class.getClassLoader(), /* isParent = */ false);
        // Also delegate to system classloader, in case the above two are actually the same as `classLoader`
        classLoaderOrder.delegateTo(ClassLoader.getSystemClassLoader(), /* isParent = */ true);
        // Finally delegate to the parent of the RestartClassLoader, in case that is different from
        // SystemClassLoader
        classLoaderOrder.delegateTo(classLoader.getParent(), /* isParent = */ true);
    }
485570
private URL getUrl() {
		ClassLoader loader = Thread.currentThread().getContextClassLoader();
		URL url = loader.getResource(this.getPath());
		return url;
	}
210367
public static final ClassLoader getContextLoader() {
		return CClassLoader.contextLoader.get() != null ? (CClassLoader) ((WeakReference) CClassLoader.contextLoader
				.get()).get()
				: null;
	}
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);
			}
		}
	}
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;
		}
	}
563288
public static ClassLoader getContextClassLoader() {
        return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
            @Override
            public ClassLoader run() {
                ClassLoader cl = null;
                try {
                    cl = Thread.currentThread().getContextClassLoader();
                } catch (final SecurityException ex) {
                    // fall through
                }
                return cl;
            }
        });
    }