summaryrefslogtreecommitdiff
path: root/src/main/java/com/keuin/kbackupfabric/util/ReflectionUtils.java
diff options
context:
space:
mode:
authorKeuin <[email protected]>2023-01-13 02:49:57 +0800
committerKeuin <[email protected]>2023-01-13 02:49:57 +0800
commit5dc6e700cbcbc01833a02a193f660a286b934898 (patch)
tree72cf4cc3cfae2b3a7fb978bc0c465e329909db3e /src/main/java/com/keuin/kbackupfabric/util/ReflectionUtils.java
parentff7d23b5b915f04c2b5f3614701cb56cfc605228 (diff)
Code cleanup.
Diffstat (limited to 'src/main/java/com/keuin/kbackupfabric/util/ReflectionUtils.java')
-rw-r--r--src/main/java/com/keuin/kbackupfabric/util/ReflectionUtils.java28
1 files changed, 5 insertions, 23 deletions
diff --git a/src/main/java/com/keuin/kbackupfabric/util/ReflectionUtils.java b/src/main/java/com/keuin/kbackupfabric/util/ReflectionUtils.java
index 2acc562..6fb1e3f 100644
--- a/src/main/java/com/keuin/kbackupfabric/util/ReflectionUtils.java
+++ b/src/main/java/com/keuin/kbackupfabric/util/ReflectionUtils.java
@@ -12,11 +12,7 @@ import java.lang.reflect.Method;
public final class ReflectionUtils {
/**
- * 获取私有成员变量的值
- *
- * @param instance
- * @param filedName
- * @return
+ * Read private fields.
*/
public static Object getPrivateField(Object instance, String filedName) throws NoSuchFieldException, IllegalAccessException {
Field field = instance.getClass().getDeclaredField(filedName);
@@ -25,13 +21,7 @@ public final class ReflectionUtils {
}
/**
- * 设置私有成员的值
- *
- * @param instance
- * @param fieldName
- * @param value
- * @throws NoSuchFieldException
- * @throws IllegalAccessException
+ * Modify private fields.
*/
public static void setPrivateField(Object instance, String fieldName, Object value) throws NoSuchFieldException, IllegalAccessException {
Field field = instance.getClass().getDeclaredField(fieldName);
@@ -40,18 +30,10 @@ public final class ReflectionUtils {
}
/**
- * 访问私有方法
- *
- * @param instance
- * @param methodName
- * @param classes
- * @param objects
- * @return
- * @throws NoSuchMethodException
- * @throws InvocationTargetException
- * @throws IllegalAccessException
+ * Call private methods.
*/
- public static Object invokePrivateMethod(Object instance, String methodName, Class[] classes, String objects) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
+ public static Object invokePrivateMethod(Object instance, String methodName, Class<?>[] classes, String objects)
+ throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
Method method = instance.getClass().getDeclaredMethod(methodName, classes);
method.setAccessible(true);
return method.invoke(instance, objects);