Per*_*cot 3 java-native-interface
我正在编写一个调用System.exit()的java库的C接口.我打电话:
/* Calls the main method for the class */
printf("about to call main\n");
(*env)->CallStaticVoidMethod(env, mainClass, mainMethod, args);
printf("returning from main\n");
Run Code Online (Sandbox Code Playgroud)
我(遗憾的是)没有更改库的选项,但我仍然希望JVM将控制权返回给C调用函数(所以我可以做各种清理任务等等).有没有办法让JNI这样做,或者我是SOL?
谢谢,
对于这么简单的情况,你不需要字节码编辑,在很好的旧java中实现了很多安全处理.
System.setSecurityManager(SecurityManager)抛出一些错误(如ThreadDeath)checkExit()并假设System.exit(int)[erm Runtime.getRuntime().exit(int)]在同一个线程中被调用,它应该这样做.
| 归档时间: |
|
| 查看次数: |
1394 次 |
| 最近记录: |