JDK-8094113 : [Quantum] SecurityException on exit when running any FX program with security manager
  • Type: Bug
  • Component: javafx
  • Sub-Component: graphics
  • Affected Version: 8u20
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2014-03-15
  • Updated: 2015-06-12
  • Resolved: 2014-03-17
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 8
8u20Fixed
Related Reports
Relates :  
Description
I discovered this while implementing the tests for RT-36197. To reproduce:

1) Run any FX program with a security manager, for example:

    java -Djava.security.manager -cp dist/Hello.jar hello.HelloRectangle

The program should come up and run fine.

2) Close the window by pressing the window close button.

The following exception will be thrown by the dispose code:

Exception in thread "JavaFX Application Thread" java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "shutdownHooks")
	at java.security.AccessControlContext.checkPermission(AccessControlContext.java:457)
	at java.security.AccessController.checkPermission(AccessController.java:884)
	at java.lang.SecurityManager.checkPermission(SecurityManager.java:549)
	at java.lang.Runtime.removeShutdownHook(Runtime.java:237)
	at com.sun.javafx.tk.quantum.QuantumToolkit.dispose(QuantumToolkit.java:706)
	at com.sun.javafx.tk.quantum.QuantumToolkit.exit(QuantumToolkit.java:695)
	at com.sun.javafx.application.PlatformImpl$10.run(PlatformImpl.java:465)
	at com.sun.javafx.application.PlatformImpl$7.run(PlatformImpl.java:335)
	at com.sun.javafx.application.PlatformImpl$6$1.run(PlatformImpl.java:301)
	at com.sun.javafx.application.PlatformImpl$6$1.run(PlatformImpl.java:298)
	at java.security.AccessController.doPrivileged(Native Method)
	at com.sun.javafx.application.PlatformImpl$6.run(PlatformImpl.java:298)
	at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
	at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
	at com.sun.glass.ui.win.WinApplication.access$300(WinApplication.java:39)
	at com.sun.glass.ui.win.WinApplication$4$1.run(WinApplication.java:112)
	at java.lang.Thread.run(Thread.java:744)

Comments
Tested with various programs running with / without a security manager.
17-03-2014

http://hg.openjdk.java.net/openjfx/8u-dev/rt/rev/73f0beec1171
17-03-2014

+1.
17-03-2014

approved.
16-03-2014

Regression tests will be covered by RT-36197 (which I will send out for review soon).
15-03-2014

Please review the following: http://cr.openjdk.java.net/~kcr/RT-36232/ Reviewers: felipe, anthony As mentioned in the above comment, the simple fix is to remove the shutdown hook from within a doPrivileged block.
15-03-2014

The fix is the remove the shutdown hook from within a doPrivileged call. Note that the corresponding add of the shutdown hook is already done in a diPrivileged call.
15-03-2014