Commit 55fc95dd authored by 张森's avatar 张森

Access Specifier Manipulation(访问指定符操作) 问题修复

parent 1198a5a4
...@@ -60,7 +60,7 @@ public class ReflectUtil ...@@ -60,7 +60,7 @@ public class ReflectUtil
Method method = clazz.getDeclaredMethod(methodname, ftype); // 获取定义的方法 Method method = clazz.getDeclaredMethod(methodname, ftype); // 获取定义的方法
if (!Modifier.isPublic(method.getModifiers())) if (!Modifier.isPublic(method.getModifiers()))
{ // 设置非共有方法权限 { // 设置非共有方法权限
method.setAccessible(true); ReflectionUtils.makeAccessible(method);
} }
method.invoke(target, fvalue); // 执行方法回调 method.invoke(target, fvalue); // 执行方法回调
} }
...@@ -71,7 +71,6 @@ public class ReflectUtil ...@@ -71,7 +71,6 @@ public class ReflectUtil
Field field = clazz.getDeclaredField(fname); // 获取定义的类属性 Field field = clazz.getDeclaredField(fname); // 获取定义的类属性
if (!Modifier.isPublic(field.getModifiers())) if (!Modifier.isPublic(field.getModifiers()))
{ // 设置非共有类属性权限 { // 设置非共有类属性权限
// field.setAccessible(true);
ReflectionUtils.makeAccessible(field); ReflectionUtils.makeAccessible(field);
} }
field.set(target, fvalue); // 设置类属性值 field.set(target, fvalue); // 设置类属性值
...@@ -117,7 +116,7 @@ public class ReflectUtil ...@@ -117,7 +116,7 @@ public class ReflectUtil
Method method = clazz.getDeclaredMethod(methodname); // 获取定义的方法 Method method = clazz.getDeclaredMethod(methodname); // 获取定义的方法
if (!Modifier.isPublic(method.getModifiers())) if (!Modifier.isPublic(method.getModifiers()))
{ // 设置非共有方法权限 { // 设置非共有方法权限
method.setAccessible(true); ReflectionUtils.makeAccessible(method);
} }
return method.invoke(target); // 方法回调,返回值 return method.invoke(target); // 方法回调,返回值
} }
...@@ -132,7 +131,6 @@ public class ReflectUtil ...@@ -132,7 +131,6 @@ public class ReflectUtil
Field field = clazz.getDeclaredField(fname); // 获取定义的类属性 Field field = clazz.getDeclaredField(fname); // 获取定义的类属性
if (!Modifier.isPublic(field.getModifiers())) if (!Modifier.isPublic(field.getModifiers()))
{ // 设置非共有类属性权限 { // 设置非共有类属性权限
// field.setAccessible(true);
ReflectionUtils.makeAccessible(field); ReflectionUtils.makeAccessible(field);
} }
return field.get(target);// 返回类属性值 return field.get(target);// 返回类属性值
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment