public final class ClassLoaderUtils extends Object
| Modifier and Type | Method and Description |
|---|---|
static Object |
construct(Constructor<?> constructor,
List<Object> objects) |
static <S,G,P> Class<P> |
findFirstGenericArgument(Class<S> scannedClass,
Class<G> genericType) |
static ParameterizedType |
findParameterizedType(Class<?> subclass,
Class<?> genericType) |
static Type |
getFirstGenericParameter(Type type) |
static Class<?> |
loadClass(ClassLoader cls,
String name)
Loads class using this supplied classloader.
|
static Class<?> |
loadClassWithTCCL(String name) |
static Class<?> |
tryToLoadClassWithTCCL(String fullyQualifiedClassName) |
static <V> V |
withClassLoader(ClassLoader cls,
Callable<V> function)
Runs
Callable with provided ClassLoader. |
static <V> V |
withClassLoader(ClassLoader cls,
com.google.common.base.Supplier<V> function)
Runs
Supplier with provided ClassLoader. |
public static <V> V withClassLoader(ClassLoader cls, com.google.common.base.Supplier<V> function)
Supplier with provided ClassLoader.
Invokes supplies function and makes sure that original ClassLoader
is context ClassLoader after execution.
cls - ClassLoader to be used.function - Function to be executed.public static <V> V withClassLoader(ClassLoader cls, Callable<V> function) throws Exception
Callable with provided ClassLoader.
Invokes supplies function and makes sure that original ClassLoader
is context ClassLoader after execution.cls - ClassLoader to be used.function - Function to be executed.Exceptionpublic static Object construct(Constructor<?> constructor, List<Object> objects) throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException
public static Class<?> loadClass(ClassLoader cls, String name) throws ClassNotFoundException
name - String name of class.ClassNotFoundExceptionpublic static Class<?> loadClassWithTCCL(String name) throws ClassNotFoundException
ClassNotFoundExceptionpublic static Class<?> tryToLoadClassWithTCCL(String fullyQualifiedClassName)
public static <S,G,P> Class<P> findFirstGenericArgument(Class<S> scannedClass, Class<G> genericType)
public static ParameterizedType findParameterizedType(Class<?> subclass, Class<?> genericType)
Copyright © 2018 OpenDaylight. All rights reserved.