首页 > 解决方案 > 我如何使用 SecurityManager 反射使 String + 对象变为空

问题描述

public class Test {
    public static void main(String[] args) throws NoSuchFieldException, IllegalAccessException {
        System.setSecurityManager(new SecurityManager(){
            @Override
            public void checkPermission(Permission perm) {
            }
        });
        doSomething();
        System.out.println("if success" + System.getSecurityManager()==null);
    }
    public static void doSomething() throws NoSuchFieldException, IllegalAccessException {
        //use reflection
        //Only allow answers within this method, so that the final output of 
        //the main method is true.
    }
}

我应该在doSomethis()方法中写什么?

标签: javareflection

解决方案


推荐阅读