public class ClassReference extends Object
| Constructor and Description |
|---|
ClassReference(Object o)
Constructor.
|
ClassReference(String className)
Contructor.
|
| Modifier and Type | Method and Description |
|---|---|
Class[] |
getClasses()
Returns all superclasses.
|
Object |
getField(String field_name)
Returns the field value.
|
Object |
invokeMethod(String method_name,
Object[] params,
Class[] params_classes)
Locates method by name and parameter types and executes it.
|
Object |
newInstance(Object[] params,
Class[] params_classes)
Locates constructor by parameter types and creates an instance.
|
void |
setField(String field_name,
Object newValue)
Change a field's value.
|
void |
startApplication()
Executes class's
main(java.lang.String[]) method
with a zero-length java.lang.String array
as a parameter. |
void |
startApplication(String[] params)
Executes class's
main(java.lang.String[]) method. |
public ClassReference(Object o)
o - Object to work with.public ClassReference(String className) throws ClassNotFoundException
className - name of classClassNotFoundExceptionpublic void startApplication()
throws InvocationTargetException,
NoSuchMethodException
main(java.lang.String[]) method
with a zero-length java.lang.String array
as a parameter.public void startApplication(String[] params) throws InvocationTargetException, NoSuchMethodException
main(java.lang.String[]) method.params - The java.lang.String array to pass
to main(java.lang.String[]).NoSuchMethodExceptionInvocationTargetExceptionpublic Object invokeMethod(String method_name, Object[] params, Class[] params_classes) throws InvocationTargetException, NoSuchMethodException, IllegalAccessException
method_name - Name of method.params - Method parameters.params_classes - Method parameters types.method_name method is void, null is returned.method_name method returns a primitive type, then
return wrapper class instance.InvocationTargetException - when the invoked method throws an exception.NoSuchMethodException - when the method cannot be found.IllegalAccessException - when access to the class or method is lacking.SecurityException - if access to the package or method is denied.IllegalAccessExceptionNoSuchMethodExceptionInvocationTargetExceptionpublic Object newInstance(Object[] params, Class[] params_classes) throws InvocationTargetException, NoSuchMethodException, IllegalAccessException, InstantiationException
params - An array of Method parameters.params_classes - An array of Method parameter types.InvocationTargetException - when the invoked constructor throws an exception.NoSuchMethodException - when the constructor cannot be found.IllegalAccessException - when access to the class or constructor is lacking.InstantiationException - when the constructor is for an abstract class.SecurityException - if access to the package or constructor is denied.IllegalAccessExceptionNoSuchMethodExceptionInstantiationExceptionInvocationTargetExceptionpublic Object getField(String field_name) throws NoSuchFieldException, IllegalAccessException
field_name - The name of the field.NoSuchFieldException - when the field cannot be found.IllegalAccessException - when access to the class or constructor is lacking.SecurityException - if access to the package or field is denied.IllegalAccessExceptionNoSuchFieldExceptionsetField(java.lang.String, java.lang.Object)public void setField(String field_name, Object newValue) throws NoSuchFieldException, IllegalAccessException
field_name - The name of the field.newValue - The fields new value.NoSuchFieldException - when the field cannot be found.IllegalAccessException - when access to the class or constructor is lacking.SecurityException - if access to the package or field is denied.IllegalAccessExceptionNoSuchFieldExceptiongetField(java.lang.String)public Class[] getClasses()
java.lang.Object.