Commit 5eca641c authored by 张森's avatar 张森

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

parent 040807a7
...@@ -32,7 +32,8 @@ public class DynamicEnumUtil { ...@@ -32,7 +32,8 @@ public class DynamicEnumUtil {
* 从而使反射允许我们修改静态final字段。 * 从而使反射允许我们修改静态final字段。
*/ */
Field modifiersField = Field.class.getDeclaredField("modifiers"); Field modifiersField = Field.class.getDeclaredField("modifiers");
modifiersField.setAccessible(true); // 反射访问私有变量
ReflectionUtils.makeAccessible(modifiersField);
int modifiers = modifiersField.getInt(field); int modifiers = modifiersField.getInt(field);
// 去掉修饰符int中的最后一位 // 去掉修饰符int中的最后一位
......
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