JDK-8156078 : Stage alwaysOnTop property not reset to false if permission is denied
  • Type: Bug
  • Component: javafx
  • Sub-Component: graphics
  • Affected Version: 8u40,9
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2016-05-05
  • Updated: 2020-01-31
  • Resolved: 2016-08-05
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.
8u152Fixed 9Fixed
Related Reports
Relates :  
To reproduce, run the attached test with a security manager:

java -Djava.security.manager AlwaysOnTopTest

It will (correctly) not be granted permission to be always on top. However, if you click the button it will report that the stage is always on top.

Verified with 8u152b01/Win10(x64) , now correctly setting alwaysOnTop property to be false and printing AlwaysOnTop: false on clicking.


Please review the proposed backport: http://cr.openjdk.java.net/~ckyang/JDK-8156078/backport.00/

Changeset: c46f3715c611 Author: ckyang Date: 2016-08-05 10:08 -0700 URL: http://hg.openjdk.java.net/openjfx/9-dev/rt/rev/c46f3715c611

Approved to backport to 8u-dev for 8u122.


Thanks for the good catch that I have overlooked too. http://cr.openjdk.java.net/~ckyang/JDK-8156078/webrev.02/

Sorry for missing this earlier: + } else { + if (stageListener != null) { + alwaysOnTop = false; + stageListener.changedAlwaysOnTop(alwaysOnTop); + } The setting of alwaysOnTop = false; must be done outside the test for stageListener or an incorrect value could be saved in the isAlwaysOnTop instance variable.

Thanks for the suggestion. Here is the improved fix: http://cr.openjdk.java.net/~ckyang/JDK-8156078/webrev.01/

The following code could be made more robust: if (alwaysOnTop) { if (hasPermission(SET_WINDOW_ALWAYS_ON_TOP_PERMISSION)) { platformWindow.setLevel(Level.FLOATING); + } else { + if (stageListener != null) { + stageListener.changedAlwaysOnTop(false); + } If the window already was "alwaysOnTop" (e.g., by a prior call that did have permission) then this would incorrectly set it back to false. To make it more robust, you would want to save the value of alwaysOnTop and only execute this block of code if the user is trying to set it to a value that is different from the previous saved value.

Please review the proposed fix: http://cr.openjdk.java.net/~ckyang/JDK-8156078/webrev.00/