开发者

What does shutdownHooks RuntimePermission does?

I saw that to show a JOptionPane message dialog I need the shutdown开发者_如何学JAVAHooks permition. What does it do? And what's the possible risk of give this permission to third party code?


A shutdown hook is code that will be run by the VM before it exits (after all of the non-daemon threads have completed). That permission allows code to register one of these hooks (or unregister existing hooks) with the VM. The documentation lists the potential risks as "This allows an attacker to register a malicious shutdown hook that interferes with the clean shutdown of the virtual machine." (taken from the official documentation). Basically code would be able to disrupt the normal termination of the VM. Some possible examples are causing it to exit with a return code other than what it would normally or causing the VM to hang and not shutdown at all. That said I don't think there are a great deal of risks outside of those that normally running code would pose, and shutdown hooks are still be subject to the SecurityManager.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜