javax/swing/JMenuItem/ActionListenerCalledTwice/ActionListenerCalledTwiceTest.java is repeatedly failing on macOS 12
https://docs.oracle.com/en/java/javase/11/docs/api/java.desktop/java/awt/Desktop.html#setDefaultMenuBar(javax.swing.JMenuBar)
provides a menu bar that can still be accessed when there are no active frames.
This is using the system menu bar on maOS and was implemented as part of https://openjdk.java.net/jeps/272
The test effectively runs twice once with the window active and again iconified.
It is the latter which fails because no events are delivered and we get
Exception in thread "main" java.lang.Exception: DefaultMenuBar Test failed: ActionListener for Item1 called 0 times instead of 1!
at ActionListenerCalledTwiceTest.testForTwice(ActionListenerCalledTwiceTest.java:114)
at ActionListenerCalledTwiceTest.main(ActionListenerCalledTwiceTest.java:48)
It appears that in this test when the app is in the iconfied state the test is expecting the keystrokes to go
to this menu bar still. I don't know if the expecation is correct, but this isn't happening and worked in earlier versions of macOS
Also I noticed that the test doesn't exit. It appears that the call to
Desktop.getDesktop().setDefaultMenuBar(bar);
is effectively creating another visible window so the AWT thread doesn't exit.
Adding this line below allows the test to exit and should be added to the test
SwingUtilities.invokeAndWait(() -> Desktop.getDesktop().setDefaultMenuBar(null));
One thing it I noticed tho' i that the spec of this method doesn't actually say null is allowed ..
It might be a good idea to update it - probably as a separate bug since any fix to this may need
to be backported.
https://docs.oracle.com/en/java/javase/11/docs/api/java.desktop/java/awt/Desktop.html#setDefaultMenuBar(javax.swing.JMenuBar)
provides a menu bar that can still be accessed when there are no active frames.
This is using the system menu bar on maOS and was implemented as part of https://openjdk.java.net/jeps/272
The test effectively runs twice once with the window active and again iconified.
It is the latter which fails because no events are delivered and we get
Exception in thread "main" java.lang.Exception: DefaultMenuBar Test failed: ActionListener for Item1 called 0 times instead of 1!
at ActionListenerCalledTwiceTest.testForTwice(ActionListenerCalledTwiceTest.java:114)
at ActionListenerCalledTwiceTest.main(ActionListenerCalledTwiceTest.java:48)
It appears that in this test when the app is in the iconfied state the test is expecting the keystrokes to go
to this menu bar still. I don't know if the expecation is correct, but this isn't happening and worked in earlier versions of macOS
Also I noticed that the test doesn't exit. It appears that the call to
Desktop.getDesktop().setDefaultMenuBar(bar);
is effectively creating another visible window so the AWT thread doesn't exit.
Adding this line below allows the test to exit and should be added to the test
SwingUtilities.invokeAndWait(() -> Desktop.getDesktop().setDefaultMenuBar(null));
One thing it I noticed tho' i that the spec of this method doesn't actually say null is allowed ..
It might be a good idea to update it - probably as a separate bug since any fix to this may need
to be backported.
- relates to
-
JDK-8278348 [macos12] javax/swing/JTree/4908142/bug4908142.java fails in macos12
- Resolved