java - 我如何使用 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()
方法中写什么?
解决方案
推荐阅读
- java - Context.openFileInput 和 Context.openFileOutput 之间的同步
- java - 在 JPA 中使用 FetchMode.SUBSELECT 替代休眠 @FetchProfile
- uwp - 如何在 WinJS 中实现二维码扫描器
- mysql - MYSQL,错误 1062
- regex - 从powershell字符串中提取整数
- javascript - firebase auth 不是一个函数
- scala - 如何用值“未定义”替换值“未知”?
- sql - Pentaho (spoon):为 SQL 中的多行生成主键
- reactjs - 什么是用于快照测试的 react-scripts Jest 默认序列化程序?
- android - Firebase-ui 错误