程序包 com.alazeprt
类 DependencyClass
java.lang.Object
com.alazeprt.DependencyClass
A utility class for invoking instance and static methods using reflection.
-
构造器概要
构造器构造器说明DependencyClass(Object object) Constructs an instance of DependencyClass with the specified object. -
方法概要
修饰符和类型方法说明Retrieves the object stored in the class.Invokes an instance method on the specified object.static ObjectrunStaticMethod(DependencyLoader loader, String className, String methodName, Object... args) Invokes a static method on the specified class using the provided class loader.runStaticMethod(String methodName, Object... args) Invokes a static method on the class of the underlying object.
-
构造器详细资料
-
DependencyClass
Constructs an instance of DependencyClass with the specified object.- 参数:
object- The object on which methods will be invoked.
-
-
方法详细资料
-
runMethod
public Object runMethod(String methodName, Object... args) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException Invokes an instance method on the specified object.- 参数:
methodName- The name of the method to invoke.args- The arguments to pass to the method.- 返回:
- The result of invoking the method.
- 抛出:
NoSuchMethodException- If the method with the specified name and parameter types is not found.InvocationTargetException- If the method throws an exception.IllegalAccessException- If access to the method is denied.
-
runStaticMethod
public static Object runStaticMethod(DependencyLoader loader, String className, String methodName, Object... args) throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, IllegalAccessException Invokes a static method on the specified class using the provided class loader.- 参数:
loader- The DependencyLoader instance used for class loading.className- The fully qualified class name containing the static method.methodName- The name of the static method to invoke.args- The arguments to pass to the method.- 返回:
- The result of invoking the static method.
- 抛出:
ClassNotFoundException- If the class is not found.NoSuchMethodException- If the method with the specified name and parameter types is not found.InvocationTargetException- If the method throws an exception.IllegalAccessException- If access to the method is denied.
-
runStaticMethod
public Object runStaticMethod(String methodName, Object... args) throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, IllegalAccessException Invokes a static method on the class of the underlying object.- 参数:
methodName- The name of the static method to invoke.args- The arguments to pass to the method.- 返回:
- The result of invoking the static method.
- 抛出:
ClassNotFoundException- If the class is not found.NoSuchMethodException- If the method with the specified name and parameter types is not found.InvocationTargetException- If the method throws an exception.IllegalAccessException- If access to the method is denied.
-
getObject
Retrieves the object stored in the class.- 返回:
- the object stored in the class
-