File tree Expand file tree Collapse file tree 1 file changed +25
-1
lines changed
src/main/java/com/falsepattern/lib/internal Expand file tree Collapse file tree 1 file changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -31,13 +31,37 @@ public class ReflectionUtil {
31
31
32
32
static {
33
33
try {
34
- f_modifiers = Field . class . getDeclaredField ( "modifiers" );
34
+ f_modifiers = getModifiersField ( );
35
35
} catch (NoSuchFieldException e ) {
36
36
throw new RuntimeException (e );
37
37
}
38
38
f_modifiers .setAccessible (true );
39
39
}
40
40
41
+ // ref: https://github.com/prestodb/presto/pull/15240/files#diff-8bf996e5c1d4fb088b84ae0528bc42686b0724bcf5a2692a1e7b5eff32c90cce
42
+ private static Field getModifiersField () throws NoSuchFieldException
43
+ {
44
+ try {
45
+ return Field .class .getDeclaredField ("modifiers" );
46
+ }
47
+ catch (NoSuchFieldException e ) {
48
+ try {
49
+ Method getDeclaredFields0 = Class .class .getDeclaredMethod ("getDeclaredFields0" , boolean .class );
50
+ getDeclaredFields0 .setAccessible (true );
51
+ Field [] fields = (Field []) getDeclaredFields0 .invoke (Field .class , false );
52
+ for (Field field : fields ) {
53
+ if ("modifiers" .equals (field .getName ())) {
54
+ return field ;
55
+ }
56
+ }
57
+ }
58
+ catch (ReflectiveOperationException ex ) {
59
+ e .addSuppressed (ex );
60
+ }
61
+ throw e ;
62
+ }
63
+ }
64
+
41
65
@ SneakyThrows
42
66
public static void jailBreak (Field field ) {
43
67
field .setAccessible (true );
You can’t perform that action at this time.
0 commit comments