【问题标题】:Preventing JVM from executing System.exit()阻止 JVM 执行 System.exit()
【发布时间】:2011-04-06 09:39:50
【问题描述】:

如何防止执行 System.exit()。如果在代码中间调用 exit() 方法。 JVM应该抛出编译时异常

【问题讨论】:

  • 不存在“编译时异常”。

标签: java


【解决方案1】:

does this thread help?

否则/简而言之,您可以像这样实现自己的安全管理器:

class MySecurityManager extends SecurityManager {
  @Override public void checkExit(int status) {
    throw new SecurityException();
  }
}

【讨论】:

    猜你喜欢
    • 2011-07-29
    • 1970-01-01
    • 2016-06-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-10-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多