Advertisement
HaxiDenti

Java - disable 'Illegal reflective exception'

Feb 20th, 2019
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.51 KB | None | 0 0
  1. public static void disableIllegalWarning() {
  2.         try {
  3.             Field theUnsafe = Unsafe.class.getDeclaredField("theUnsafe");
  4.             theUnsafe.setAccessible(true);
  5.             Unsafe u = (Unsafe) theUnsafe.get(null);
  6.  
  7.             Class cls = Class.forName("jdk.internal.module.IllegalAccessLogger");
  8.             Field logger = cls.getDeclaredField("logger");
  9.             u.putObjectVolatile(cls, u.staticFieldOffset(logger), null);
  10.         } catch (Exception e) {
  11.             // ignore
  12.         }
  13.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement