java调用unsafe方法

public static Unsafe reflectGetUnsafe() {
        try {
            Field field = Unsafe.class.getDeclaredField("theUnsafe");
            field.setAccessible(true);
            return (Unsafe) field.get(null);
        } catch (NoSuchFieldException | IllegalAccessException e) {
            e.printStackTrace();
        }
        return null;
    }

 

posted @ 2022-03-31 17:45  甜菜波波  阅读(54)  评论(0编辑  收藏  举报