IDEA 启动项目警告WARNING: An illegal reflective access operation has occurred

貌似是jdk版本不兼容但是我已经是用的JDK11
启动时添加一个方法就可以去除讨厌的警告
WARNING: An illegal reflective access operation has occurred

   /**
     * 去除Warning
     */
    public static void disableWarning() {
        try {
            Field theUnsafe = Unsafe.class.getDeclaredField("theUnsafe");
            theUnsafe.setAccessible(true);
            Unsafe u = (Unsafe) theUnsafe.get(null);
            Class cls = Class.forName("jdk.internal.module.IllegalAccessLogger");
            Field logger = cls.getDeclaredField("logger");
            u.putObjectVolatile(cls, u.staticFieldOffset(logger), null);
        } catch (Exception e) {
        }
    }



你可能感兴趣的:(IDEA 启动项目警告WARNING: An illegal reflective access operation has occurred)