public class ReflectiveMethodCallUtil
extends java.lang.Object
ReflectiveMethodCallUtil can execute a method call on a given class reflectively.
If the call fails, a RuntimeException is thrown, otherwise, a new Value is returned using the
given factory.| Constructor and Description |
|---|
ReflectiveMethodCallUtil() |
| Modifier and Type | Method and Description |
|---|---|
static java.lang.Object |
callConstructor(java.lang.String className,
java.lang.Class<?>[] parameterClasses,
java.lang.Object[] parameterObjects)
Reflectively call the constructor of className with the given parameters.
|
static java.lang.Object |
callMethod(java.lang.String className,
java.lang.String methodName,
java.lang.Object instance,
java.lang.Class<?>[] parameterClasses,
java.lang.Object[] parameterObjects)
Reflectively call the method on the given instance.
|
static java.lang.Class<?> |
getClassForPrimitive(char internalPrimitiveType)
Returns the Class for the given primitive type.
|
static java.lang.Object |
getObjectForValue(Value value,
java.lang.Class<?> expectedType)
Extract the Object from the given Value.
|
static java.lang.Class<?>[] |
stringtypesToClasses(java.lang.String descriptor)
Reflectively converts a method descriptor to a list of Classes representing this String.
|
public static java.lang.Class<?>[] stringtypesToClasses(java.lang.String descriptor)
throws java.lang.ClassNotFoundException
java.lang.ClassNotFoundException - if one of the referenced classes (as string) is not part of the current class pool.public static java.lang.Object getObjectForValue(Value value, java.lang.Class<?> expectedType)
value - the value holding the object.expectedType - the class the returned object should be.public static java.lang.Class<?> getClassForPrimitive(char internalPrimitiveType)
public static java.lang.Object callConstructor(java.lang.String className,
java.lang.Class<?>[] parameterClasses,
java.lang.Object[] parameterObjects)
throws java.lang.ClassNotFoundException,
java.lang.NoSuchMethodException,
java.lang.IllegalAccessException,
java.lang.reflect.InvocationTargetException,
java.lang.InstantiationException
java.lang.ClassNotFoundExceptionjava.lang.NoSuchMethodExceptionjava.lang.IllegalAccessExceptionjava.lang.reflect.InvocationTargetExceptionjava.lang.InstantiationExceptionpublic static java.lang.Object callMethod(java.lang.String className,
java.lang.String methodName,
java.lang.Object instance,
java.lang.Class<?>[] parameterClasses,
java.lang.Object[] parameterObjects)
throws java.lang.reflect.InvocationTargetException,
java.lang.IllegalAccessException,
java.lang.NoSuchMethodException,
java.lang.ClassNotFoundException
java.lang.reflect.InvocationTargetExceptionjava.lang.IllegalAccessExceptionjava.lang.NoSuchMethodExceptionjava.lang.ClassNotFoundException