|
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectorg.jppf.utils.ReflectionHelper
public final class ReflectionHelper
Collection of utility methods to facilitate the use of reflection.
| Constructor Summary | |
|---|---|
ReflectionHelper()
|
|
| Method Summary | |
|---|---|
static Class |
getClass0(String className)
Transform a class name into a Class object. |
static Class[] |
getClasses(String... classNames)
Transform an array of class names into an array of Class objects. |
static ClassLoader |
getCurrentClassLoader()
Returns the current thread's context class loader, or this class's class loader if it is null. |
static Object |
getField(Class clazz,
Object instance,
String fieldName)
Get the value of the field of a specified class. |
static Object |
invokeConstructor(Class<?> clazz,
Class<?>[] paramTypes,
Object... values)
Invoke a constructor using reflection. |
static Object |
invokeMethod(Class<?> clazz,
Object instance,
String methodName,
Class<?>[] paramTypes,
Object... values)
Invoke a method using reflection. |
static Object |
invokeMethod(Class clazz,
Object instance,
String methodName)
Convenience method to invoke a method with no parameter. |
static Object |
invokeMethod(Class clazz,
Object instance,
String methodName,
Object... values)
Invoke a method using reflection, without having to specify the parameters types. |
static Object |
newInstance(String className)
Invoke a default constructor using reflection. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ReflectionHelper()
| Method Detail |
|---|
public static Object invokeMethod(Class<?> clazz,
Object instance,
String methodName,
Class<?>[] paramTypes,
Object... values)
clazz - the class on which to invoke the method.instance - the object on which to invoke the method, may be null if the method is static.methodName - the name of the method to invoke.paramTypes - the types of the method's parameters, may be null if no parameters.values - the values of the method's parameters, may be null if no parameters.
JPPFException if the invocation failed.
public static Object invokeMethod(Class clazz,
Object instance,
String methodName,
Object... values)
clazz - the class on which to invoke the method.instance - the object on which to invoke the method, may be null if the method is static.methodName - the name of the method to invoke.values - the values of the method's parameters, may be null if no parameters.
JPPFException if the invocation failed.
public static Object invokeMethod(Class clazz,
Object instance,
String methodName)
clazz - the class on which to invoke the method.instance - the object on which to invoke the method, may be null if the method is static.methodName - the name of the method to invoke.
JPPFException if the invocation failed.public static Object newInstance(String className)
className - the name of the class to instantiate.
JPPFException if the instantiation failed.
public static Object invokeConstructor(Class<?> clazz,
Class<?>[] paramTypes,
Object... values)
clazz - the class on which to invoke the constructor.paramTypes - the types of the constructor's parameters, may be null if no parameters.values - the values of the constructor's parameters, may be null if no parameters.
JPPFException if the invocation failed.
public static Object getField(Class clazz,
Object instance,
String fieldName)
clazz - the class declaring the field.instance - the class instance for which to get the field's value, may be null if the field is static.fieldName - the name of the field to get the value of.
JPPFException if the invocation failed.public static Class[] getClasses(String... classNames)
Class objects.
classNames - the names of the classes to find.
Class objects, or null if one of the classes could not be found.public static Class getClass0(String className)
Class object.
className - the name of the class to find.
Class objects, or null if one of the classes could not be found.public static ClassLoader getCurrentClassLoader()
ClassLoader instance.
|
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||