How to prevent calls to System.exit() from terminating the JVM?

前端 未结 4 1094
自闭症患者
自闭症患者 2020-12-03 13:33

I am almost certain this is impossible, but it\'s worth a try.

I am writing a command line interface for a certain tool. I am talking about a Java application that i

4条回答
  •  天涯浪人
    2020-12-03 14:18

    Regarding to this (@Vonc answer) you should use Security Manager:

    Try modifying the TestCase to run with a security manager that prevents calling System.exit, then catch the SecurityException.

提交回复
热议问题