Java – get an exit instruction from the library

To my surprise and fear, I just met system Line of exit (1); In the library I use I'm planning to contact the author of the library and ask what, but what can I do to prevent the library from killing my code (worse, using my code to kill the application)?

Maybe the library is forced to throw a SecurityException in some way. I see that exit (int) may throw a SecurityException

Solution

There is only one way I know, and that is not allowed to use system Exit is encoded by the securitymanager

public class MySecurityMgr extends SecurityManager {
   ... 

   @Override
    public void checkExit(int status) {
            throw new RuntimeException(Integer.toString(status));
    }
}
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>