JDK-8139593 : Running apps on FX 9 + JDK 8u fails when security manager is enabled
  • Type: Bug
  • Component: javafx
  • Sub-Component: graphics
  • Affected Version: 9
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2015-10-14
  • Updated: 2015-10-19
  • Resolved: 2015-10-14
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 9
9Fixed
Related Reports
Relates :  
Description
We still use JDK 8u40 or later as the boot jdk, meaning that we build FX 9-dev and run unit tests (and sanity tests) using JDK 8u. The fix for JDK-8139450 included a fallback case to handle running against an old (pre-9-b85) JDK. That fallback path works normally, but fails if there is a security manager installed and if jfxrt.jar is loaded with the extension class loader.

To reproduce this, run the following:

$ gradle --info -PFULL_TEST=true :systemTests:test

Here is the stack trace from one of the failures:

java.lang.ExceptionInInitializerError
	at com.sun.javafx.tk.quantum.QuantumToolkit.createTKStage(QuantumToolkit.java:548)
	at javafx.stage.Stage.impl_visibleChanging(Stage.java:1164)
	at javafx.stage.Window$9.invalidated(Window.java:824)
	at javafx.beans.property.BooleanPropertyBase.markInvalid(BooleanPropertyBase.java:110)
	at javafx.beans.property.BooleanPropertyBase.set(BooleanPropertyBase.java:145)
	at javafx.stage.Window.setShowing(Window.java:922)
	at javafx.stage.Window.show(Window.java:937)
	at javafx.stage.Stage.show(Stage.java:259)
	at sandbox.app.FXApp.start(FXApp.java:86)
	at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$163(LauncherImpl.java:866)
	at com.sun.javafx.application.LauncherImpl$$Lambda$57/655951.run(Unknown Source)
	at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$176(PlatformImpl.java:326)
	at com.sun.javafx.application.PlatformImpl$$Lambda$48/8061040.run(Unknown Source)
	at com.sun.javafx.application.PlatformImpl.lambda$null$174(PlatformImpl.java:295)
	at com.sun.javafx.application.PlatformImpl$$Lambda$51/28341320.run(Unknown Source)
	at java.security.AccessController.doPrivileged(Native Method)
	at com.sun.javafx.application.PlatformImpl.lambda$runLater$175(PlatformImpl.java:294)
	at com.sun.javafx.application.PlatformImpl$$Lambda$49/29104868.run(Unknown Source)
	at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
	at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
	at com.sun.glass.ui.win.WinApplication.lambda$null$148(WinApplication.java:191)
	at com.sun.glass.ui.win.WinApplication$$Lambda$39/20133689.run(Unknown Source)
	at java.lang.Thread.run(Thread.java:745)
Caused by: java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "accessClassInPackage.sun.misc")
	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.SecurityManager.checkPackageAccess(SecurityManager.java:1564)
	at java.lang.Class.checkPackageAccess(Class.java:2372)
	at java.lang.Class.checkMemberAccess(Class.java:2351)
	at java.lang.Class.getMethod(Class.java:1783)
	at com.sun.javafx.tk.quantum.GlassStage.<clinit>(GlassStage.java:68)
	... 23 more
Comments
http://hg.openjdk.java.net/openjfx/9-dev/rt/rev/6ee3406efb55
14-10-2015

+1
14-10-2015

http://cr.openjdk.java.net/~kcr/8139593/webrev.00/ This is a follow-on fix to JDK-8139450. The fallback path, which affects FX 9-dev + JDK 8uNN, which is our build/test environment, will fail to load sun.misc.SharedSecrets when there is a security manager enabled and jfxrt.jar is loaded by the extension class loader. One of our "systemTests" unit tests does this and is now failing as a result. This also affect Jigsaw builds, since the JDK fix for JDK-8137056 that moves SharedSecrets to a new package hasn't yet been synced into the JDK jake forest, whereas the fix for JDK-8139450 has. So I need to fix this issue in 9-dev (which we need anyway to get a successful unit test run) and then sync to FX 9 jake forest to allow FX apps in jake to run with a security manager enabled.
14-10-2015

The fix is to wrap the newly added reflection code that loads SharedSecrets in a doPrivileged.
14-10-2015