开发者

What does shutdownHooks RuntimePermission does?

开发者 https://www.devze.com 2022-12-23 20:49 出处:网络
I saw that to show a JOptionPane message dialog I need the shutdown开发者_如何学JAVAHooks permition.

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

精彩评论

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