JDK-6949414 : JMenu.buildMenuElementArray() endless loop
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 6u20
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_vista
  • CPU: x86
  • Submitted: 2010-05-04
  • Updated: 2016-04-28
  • Resolved: 2016-04-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.
JDK 9
9 b116Fixed
Description
FULL PRODUCT VERSION :
java version "1.6.0_20"
Java(TM) SE Runtime Environment (build 1.6.0_20-b02)
Java HotSpot(TM) Client VM (build 16.3-b01, mixed mode, sharing)

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.0.6002]

A DESCRIPTION OF THE PROBLEM :
When calling JMenu.doClick(int) on a JMenu that is part of a JPopupMenu, so having no JMenuBar at all the call to JMenu.buildMenuElementArray(JMenu leaf) hangs in an endless loop.


STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Create JPopupMenu, add JMenu into this and JMenuItem into the JMenu.

Now call doClick(10) on the JMenu.


EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
No endless loop, maybe a click, maybe nothing, but no endless loop.


REPRODUCIBILITY :
This bug can be reproduced always.

CUSTOMER SUBMITTED WORKAROUND :
Call MenuSelectionManager.defaultManager().setSelectedPath(me) in own code with an own created array like buildMenuElementArray() does but WITHOUT endless loop. Works!

Comments
I haven't run the test case. However, I am able to get a thread stuck in JMenu.buildMenuElementArray() on this Windows HotSpot version: java version "1.8.0_77" Java(TM) SE Runtime Environment (build 1.8.0_77-b03) Java HotSpot(TM) 64-Bit Server VM (build 25.77-b03, mixed mode)
01-04-2016

EVALUATION Here it the test to reproduce the problem: import javax.swing.*; public class Test extends JFrame { public static void main(String... args) throws Exception { SwingUtilities.invokeLater(new Runnable() { public void run() { JPopupMenu popup = new JPopupMenu(); JMenu menu = new JMenu(); popup.add(menu); menu.add(new JMenuItem()); menu.doClick(); } }); } }
18-05-2010