How to trap System.exit() in code called from JNI

后端 未结 1 1250
南方客
南方客 2020-12-19 22:19

I\'m writing a C interface to a java library that calls System.exit(). I call:

/* Calls the main method for the class */
printf(\"about to call main\\n\");
(         


        
相关标签:
1条回答
  • 2020-12-19 22:53

    You do not need bytecode editing for so simple case, a lot of security handling is implemented in the good old java.

    System.setSecurityManager(SecurityManager) throw some Error (like ThreadDeath) in checkExit() and assuming System.exit(int) [erm Runtime.getRuntime().exit(int)] is invoked in the same thread, it should do it.

    0 讨论(0)
提交回复
热议问题