@@ -82,10 +82,6 @@ public static void set(Object instance, Field field, Object value) {
82
82
public static <T > T getFieldO (Object instance , String name ) throws Exception {
83
83
Field f = instance .getClass ().getDeclaredField (name );
84
84
f .setAccessible (true );
85
- // hack access
86
- Field acc = Field .class .getDeclaredField ("modifiers" );
87
- acc .setAccessible (true );
88
- acc .setInt (f , f .getModifiers () & ~Modifier .FINAL );
89
85
// get
90
86
return (T ) f .get (instance );
91
87
}
@@ -101,10 +97,6 @@ public static <T> T getFieldO(Object instance, String name) throws Exception {
101
97
public static <T > T getFieldS (Class <?> clazz , String name ) throws Exception {
102
98
Field f = clazz .getDeclaredField (name );
103
99
f .setAccessible (true );
104
- // hack access
105
- Field acc = Field .class .getDeclaredField ("modifiers" );
106
- acc .setAccessible (true );
107
- acc .setInt (f , f .getModifiers () & ~Modifier .FINAL );
108
100
// get
109
101
return (T ) f .get (null );
110
102
}
@@ -120,10 +112,6 @@ public static <T> T getFieldS(Class<?> clazz, String name) throws Exception {
120
112
public static void setFieldO (Object instance , String name , Object value ) throws Exception {
121
113
Field f = instance .getClass ().getDeclaredField (name );
122
114
f .setAccessible (true );
123
- // hack access
124
- Field acc = Field .class .getDeclaredField ("modifiers" );
125
- acc .setAccessible (true );
126
- acc .setInt (f , f .getModifiers () & ~Modifier .FINAL );
127
115
// set
128
116
f .set (instance , value );
129
117
}
@@ -139,10 +127,6 @@ public static void setFieldO(Object instance, String name, Object value) throws
139
127
public static void setFieldS (Class <?> clazz , String name , Object value ) throws Exception {
140
128
Field f = clazz .getDeclaredField (name );
141
129
f .setAccessible (true );
142
- // hack access
143
- Field acc = Field .class .getDeclaredField ("modifiers" );
144
- acc .setAccessible (true );
145
- acc .setInt (f , f .getModifiers () & ~Modifier .FINAL );
146
130
// set
147
131
f .set (null , value );
148
132
}
0 commit comments