From 5dc6e700cbcbc01833a02a193f660a286b934898 Mon Sep 17 00:00:00 2001 From: Keuin Date: Fri, 13 Jan 2023 02:49:57 +0800 Subject: Code cleanup. --- .../keuin/kbackupfabric/util/ReflectionUtils.java | 28 ++++------------------ 1 file changed, 5 insertions(+), 23 deletions(-) (limited to 'src/main/java/com/keuin/kbackupfabric/util/ReflectionUtils.java') 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); -- cgit v1.2.3