-
Bug
-
Resolution: Unresolved
-
P4
-
7
-
x86
-
linux
FULL PRODUCT VERSION :
java version "1.7.0-ea"
Java(TM) SE Runtime Environment (build 1.7.0-ea-b07)
Java HotSpot(TM) Client VM (build 1.7.0-ea-b07, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
FreeBSD 7.0-CURRENT
EXTRA RELEVANT SYSTEM CONFIGURATION :
Using linux emulator
A DESCRIPTION OF THE PROBLEM :
Find parent loop of buildMenuElementArray method invoked from doClick only stops on JMenuBar.
So, doClick method of JMenu in JPopupMenu falls into infinity loop.
REGRESSION. Last worked in version mustang
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run test case and wait 5 seconds.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
All menu items can be select.
ACTUAL -
Swing EDT hangs and all menu items are inactive.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
No error messages.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;
import javax.swing.SwingUtilities;
public class TestJMenu {
public static void main(String[] args) throws Exception {
final JMenu menu = new JMenu("menu");
SwingUtilities.invokeAndWait(new Runnable() { public void run() {
menu.add(new JMenuItem("subItem"));
JPopupMenu popup = new JPopupMenu();
popup.add(menu);
popup.add(new JMenuItem("item"));
popup.show(null, 0, 0);
}});
Thread.sleep(5000);
SwingUtilities.invokeAndWait(new Runnable() { public void run() {
menu.doClick();
}});
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
extend JMenu and override doClick method using fixed buildMenuElementArray method such following:
---
private MenuElement[] buildMenuElementArrayFixed(JMenu leaf) {
List<MenuElement> elements = new LinkedList<MenuElement>();
Component current = leaf.getPopupMenu();
while (true) {
if (current instanceof JPopupMenu) {
elements.add(0, (MenuElement)current);
current = ((JPopupMenu)current).getInvoker();
} else if (current instanceof MenuElement) {
elements.add(0, (MenuElement)current);
current = current.getParent();
} else return elements.toArray(new MenuElement[0]);
}
}
java version "1.7.0-ea"
Java(TM) SE Runtime Environment (build 1.7.0-ea-b07)
Java HotSpot(TM) Client VM (build 1.7.0-ea-b07, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
FreeBSD 7.0-CURRENT
EXTRA RELEVANT SYSTEM CONFIGURATION :
Using linux emulator
A DESCRIPTION OF THE PROBLEM :
Find parent loop of buildMenuElementArray method invoked from doClick only stops on JMenuBar.
So, doClick method of JMenu in JPopupMenu falls into infinity loop.
REGRESSION. Last worked in version mustang
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run test case and wait 5 seconds.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
All menu items can be select.
ACTUAL -
Swing EDT hangs and all menu items are inactive.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
No error messages.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;
import javax.swing.SwingUtilities;
public class TestJMenu {
public static void main(String[] args) throws Exception {
final JMenu menu = new JMenu("menu");
SwingUtilities.invokeAndWait(new Runnable() { public void run() {
menu.add(new JMenuItem("subItem"));
JPopupMenu popup = new JPopupMenu();
popup.add(menu);
popup.add(new JMenuItem("item"));
popup.show(null, 0, 0);
}});
Thread.sleep(5000);
SwingUtilities.invokeAndWait(new Runnable() { public void run() {
menu.doClick();
}});
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
extend JMenu and override doClick method using fixed buildMenuElementArray method such following:
---
private MenuElement[] buildMenuElementArrayFixed(JMenu leaf) {
List<MenuElement> elements = new LinkedList<MenuElement>();
Component current = leaf.getPopupMenu();
while (true) {
if (current instanceof JPopupMenu) {
elements.add(0, (MenuElement)current);
current = ((JPopupMenu)current).getInvoker();
} else if (current instanceof MenuElement) {
elements.add(0, (MenuElement)current);
current = current.getParent();
} else return elements.toArray(new MenuElement[0]);
}
}