JDK-8342012 : javax/swing/JPopupMenu/6694823/bug6694823.java fails Windows, Linux after SM removal
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 24
  • Priority: P4
  • Status: Closed
  • Resolution: Not an Issue
  • OS: linux,windows
  • CPU: generic
  • Submitted: 2024-10-13
  • Updated: 2024-10-28
  • Resolved: 2024-10-28
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.
Other
tbdResolved
Related Reports
Relates :  
Description
javax/swing/JPopupMenu/6694823/bug6694823.java fails on windows and linux when Security Manager is removed

Originally the test was configured to throw SecurityException for the permission "setWindowAlwaysOnTop" which caused JPopupMenu.canPopupOverlapTaskBar() (which in turn calls SunToolkit.canPopupOverlapTaskBar()) to return false, thus the popup menu was positioned to appear above the taskbar without overlapping it.

https://github.com/openjdk/jdk/blob/41ee582df8c65f2f26b21e46784cf0bc4ece0585/src/java.desktop/share/classes/javax/swing/JPopupMenu.java#L428

https://github.com/openjdk/jdk/blob/41ee582df8c65f2f26b21e46784cf0bc4ece0585/src/java.desktop/share/classes/sun/awt/SunToolkit.java#L1117

With SM removed this check returns true which causes the popup to overlap the taskbar and thus the test fails on windows and linux.

On macOS the test passes since JPopupMenu's canPopupOverlapTaskBar() is overridden in LWCToolkit-Ln#900 to return false by default which is missing in WToolkit and XToolkit.

https://github.com/openjdk/jdk/blob/41ee582df8c65f2f26b21e46784cf0bc4ece0585/src/java.desktop/macosx/classes/sun/lwawt/macosx/LWCToolkit.java#L900

The solution would be to override canPopupOverlapTaskBar() in WToolkit and XToolkit similar to LWCToolkit to match native popup behavior (popups don't overlap the taskbar) on windows and linux too.
Comments
This test behaves differently on macOS vs windows, linux. After discussing it with [~aivanov] it was determined that it is the expected behavior and this is not a JDK bug. https://github.com/openjdk/jdk/pull/21498#discussion_r1816840082 Hence closing this bug as not an issue.
28-10-2024

On Notepad and MS Word the popup always appears above the taskbar and doesn't cover it. Screenshots attached.
25-10-2024

> The solution would be to override canPopupOverlapTaskBar() in WToolkit and XToolkit similar > to LWCToolkit to match native popup behavior (popups don't overlap the taskbar) on windows and linux too. Popups do overlap the taskbar at least on Windows, which is verified by javax/swing/Popup/TaskbarPositionTest.java [1] The updated test/jdk/javax/swing/JPopupMenu/6694823/bug6694823.java test in the PR 21498 [2][3] behaves as it should and shows its popup menu over the taskbar. [1] https://github.com/openjdk/jdk/blob/master/test/jdk/javax/swing/Popup/TaskbarPositionTest.java [2] https://github.com/openjdk/jdk/pull/21498 [3] https://github.com/openjdk/jdk/pull/21498#discussion_r1817116860
25-10-2024