public final class ReflectionUtil extends Object
| Modifier and Type | Method and Description |
|---|---|
static Object |
constructObject(Class<?> clazz)
Construct new object from class object.
|
static Class<?> |
createClass(String className)
Create class from class name.
|
static Object |
executeMethod(Class<?> clazz,
Object obj,
String methodName,
Class<?>[] parameterTypes,
Object[] parameters)
Execute method in object.
|
public static Class<?> createClass(String className) throws ClassNotFoundException
className - - Class name for the class to loadClassNotFoundException - If class with the given name is not found from class path.public static Object constructObject(Class<?> clazz) throws InstantiationException, IllegalAccessException, InvocationTargetException, NoSuchMethodException
clazz - - Class object from which new instance is created.NoSuchMethodException - If class has no default public constructor.InvocationTargetException - If constructor method cannot be invoked.IllegalAccessException - If constructor method cannot be called.InstantiationException - If given class cannot be instantiatedpublic static Object executeMethod(Class<?> clazz, Object obj, String methodName, Class<?>[] parameterTypes, Object[] parameters) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException
clazz - - Object's class typeobj - - Object containing the methodmethodName - - Name of the method to executeparameterTypes - - Method parameter typesparameters - - Method parameter valuesNoSuchMethodException - If given class does not contain requested method.InvocationTargetException - If given method cannot be invoked.IllegalAccessException - If given method cannot be called.Copyright © 2018. All rights reserved.