Class ReflectionUtils
java.lang.Object
org.apache.maven.surefire.api.util.ReflectionUtils
- Author:
 - Kristian Rosenvold
 
- 
Method Summary
Modifier and TypeMethodDescriptionstatic Constructor<?> getConstructor(Class<?> clazz, Class<?>... arguments) static Methodstatic Methodstatic <T> Tinstantiate(ClassLoader classLoader, String classname, Class<T> returnType) static <T> TinstantiateObject(String className, Class<?>[] types, Object[] params, ClassLoader cl) static <T> TinstantiateOneArg(ClassLoader classLoader, String className, Class<?> param1Class, Object param1) static <T> TinvokeGetter(Class<?> instanceType, Object instance, String methodName) static <T> TinvokeGetter(Object instance, String methodName) static <T> TinvokeMethodChain(Class<?>[] classesChain, String[] noArgMethodNames, Object fallback) Method chain invoker.static <T> TinvokeMethodWithArray(Object target, Method method, Object... args) static <T> TinvokeMethodWithArray2(Object target, Method method, Object... args) static <T> TinvokeSetter(Object target, Method method, Object value) static voidinvokeSetter(Object o, String name, Class<?> value1clazz, Object value) static <T> TinvokeStaticMethod(Class<?> clazz, String methodName, Class<?>[] parameterTypes, Object[] parameters) Invoker of public static no-argument method.static Class<?> loadClass(ClassLoader classLoader, String className) static <T> TnewInstance(Constructor<?> constructor, Object... params) static Class<?> reloadClass(ClassLoader classLoader, Object source) static <T> Constructor<T> tryGetConstructor(Class<T> clazz, Class<?>... arguments) static MethodtryGetMethod(Class<?> clazz, String methodName, Class<?>... parameters) static Class<?> tryLoadClass(ClassLoader classLoader, String className)  
- 
Method Details
- 
getMethod
 - 
getMethod
 - 
tryGetMethod
 - 
invokeGetter
 - 
invokeGetter
 - 
getConstructor
 - 
tryGetConstructor
 - 
newInstance
 - 
instantiate
 - 
instantiateOneArg
public static <T> T instantiateOneArg(ClassLoader classLoader, String className, Class<?> param1Class, Object param1)  - 
invokeSetter
 - 
invokeSetter
 - 
invokeMethodWithArray
 - 
invokeMethodWithArray2
public static <T> T invokeMethodWithArray2(Object target, Method method, Object... args) throws InvocationTargetException - Throws:
 InvocationTargetException
 - 
instantiateObject
public static <T> T instantiateObject(String className, Class<?>[] types, Object[] params, ClassLoader cl)  - 
tryLoadClass
 - 
loadClass
 - 
reloadClass
public static Class<?> reloadClass(ClassLoader classLoader, Object source) throws ReflectiveOperationException - Throws:
 ReflectiveOperationException
 - 
invokeStaticMethod
public static <T> T invokeStaticMethod(Class<?> clazz, String methodName, Class<?>[] parameterTypes, Object[] parameters) Invoker of public static no-argument method.- Parameters:
 clazz- class on which public static no-argumentmethodNameis invokedmethodName- public static no-argument method to be calledparameterTypes- method parameter typesparameters- method parameters- Returns:
 - value returned by 
methodName - Throws:
 RuntimeException- if no such method foundSurefireReflectionException- if the method could not be called or threw an exception. It has original cause Exception.
 - 
invokeMethodChain
public static <T> T invokeMethodChain(Class<?>[] classesChain, String[] noArgMethodNames, Object fallback) Method chain invoker.- Parameters:
 classesChain- classes to invoke on method chainnoArgMethodNames- chain of public methods to callfallback- returned value if a chain could not be invoked due to an error- Returns:
 - successfully returned value from the last method call; 
fallbackotherwise - Throws:
 IllegalArgumentException- ifclassesandnoArgMethodNameshave different array length
 
 -