public final class ClassLoaderUtils extends Object
Modifier and Type | Method and Description |
---|---|
static Object |
construct(Constructor<? extends Object> 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 fullyQualifiedName) |
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.Exception
public static Object construct(Constructor<? extends Object> constructor, List<Object> objects) throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException
public static Class<?> loadClass(ClassLoader cls, String name) throws ClassNotFoundException
cls
- name
- String name of class.ClassNotFoundException
public static Class<?> loadClassWithTCCL(String name) throws ClassNotFoundException
ClassNotFoundException
public static <S,G,P> Class<P> findFirstGenericArgument(Class<S> scannedClass, Class<G> genericType)
public static ParameterizedType findParameterizedType(Class<?> subclass, Class<?> genericType)
Copyright © 2017 OpenDaylight. All rights reserved.