public class ClassLoaders extends Object
| 限定符和类型 | 字段和说明 |
|---|---|
static ClassLoaderAccessor |
CLASS_CL_ACCESSOR |
static ClassLoaderAccessor |
SYSTEM_CL_ACCESSOR |
static ClassLoaderAccessor |
THREAD_CL_ACCESSOR |
| 限定符和类型 | 方法和说明 |
|---|---|
static boolean |
addUrl(URLClassLoader urlClassLoader,
URL jarUrl) |
static boolean |
addUrl(URLClassLoader urlClassLoader,
URL jarUrl,
boolean force) |
static <I,O> O |
doAction(ClassLoader threadContextClassLoader,
Function<I,O> action,
I input) |
static Class<?> |
forName(String fqcn)
Attempts to load the specified class name from the current thread's
context class loader, then the
current ClassLoader (ClassUtils.class.getClassLoader()), then the system/application
ClassLoader (ClassLoader.getSystemClassLoader(), in that order. |
static ClassLoader |
getClassLoader(Class<?> clazz) |
static ClassLoader |
getContextClassLoader() |
static ClassLoader |
getDefaultClassLoader() |
static ClassLoader |
getExtClassLoader() |
static JarFile |
getJarFile(Class<?> klass) |
static URL |
getJarUrl(Class<?> klass) |
static InputStream |
getResourceAsStream(String name) |
static ClassLoader |
getSystemClassLoader() |
static boolean |
hasClass(String classFQN,
ClassLoader classLoader) |
static boolean |
isAvailable(String fullyQualifiedClassName) |
static Class |
loadClass(String className) |
static Class |
loadClass(String className,
Class basedClass) |
static Class |
loadClass(String className,
ClassLoader classLoader) |
static Class |
loadImplClass(String className,
ClassLoader classLoader,
Class superClass) |
public static final ClassLoaderAccessor THREAD_CL_ACCESSOR
public static final ClassLoaderAccessor CLASS_CL_ACCESSOR
public static final ClassLoaderAccessor SYSTEM_CL_ACCESSOR
public static ClassLoader getClassLoader(Class<?> clazz)
public static ClassLoader getContextClassLoader()
public static ClassLoader getExtClassLoader()
public static ClassLoader getSystemClassLoader()
public static Class loadClass(@NonNull String className) throws ClassNotFoundException
public static Class loadClass(@NonNull String className, @Nullable Class basedClass) throws ClassNotFoundException
public static Class loadClass(@NonNull String className, @Nullable ClassLoader classLoader) throws ClassNotFoundException
public static Class loadImplClass(@NonNull String className, @Nullable ClassLoader classLoader, Class superClass) throws ClassNotFoundException
public static <I,O> O doAction(@NonNull ClassLoader threadContextClassLoader, @NonNull Function<I,O> action, @Nullable I input)
public static ClassLoader getDefaultClassLoader()
public static boolean hasClass(@NonNull String classFQN, @Nullable ClassLoader classLoader)
public static Class<?> forName(String fqcn) throws ClassNotFoundException
context class loader, then the
current ClassLoader (ClassUtils.class.getClassLoader()), then the system/application
ClassLoader (ClassLoader.getSystemClassLoader(), in that order. If any of them cannot locate
the specified class, an UnknownClassException is thrown (our RuntimeException equivalent of
the JRE's ClassNotFoundException.fqcn - the fully qualified class name to loadClassNotFoundException - if the class cannot be found.public static boolean isAvailable(String fullyQualifiedClassName)
public static InputStream getResourceAsStream(String name)
public static boolean addUrl(URLClassLoader urlClassLoader, URL jarUrl)
urlClassLoader - a url class loaderjarUrl - the url for a jarpublic static boolean addUrl(URLClassLoader urlClassLoader, URL jarUrl, boolean force)
urlClassLoader - a url class loaderjarUrl - the url for a jarCopyright © 2021. All rights reserved.