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 {
3131
3232 static {
3333 try {
34- f_modifiers = Field . class . getDeclaredField ( "modifiers" );
34+ f_modifiers = getModifiersField ( );
3535 } catch (NoSuchFieldException e ) {
3636 throw new RuntimeException (e );
3737 }
3838 f_modifiers .setAccessible (true );
3939 }
4040
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+
4165 @ SneakyThrows
4266 public static void jailBreak (Field field ) {
4367 field .setAccessible (true );
You can’t perform that action at this time.
0 commit comments