This fixes a problem in JMenuBar by adding a nullcheck as proposes in
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27522
2006-06-06 Roman Kennke <[EMAIL PROTECTED]>
PR 27522
* javax/swing/JMenuBar.java
(processKeyBindingHelper): Added null check to prevent NPE.
/Roman
Index: javax/swing/JMenuBar.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/JMenuBar.java,v
retrieving revision 1.23
diff -u -1 -0 -r1.23 JMenuBar.java
--- javax/swing/JMenuBar.java 13 Mar 2006 21:33:37 -0000 1.23
+++ javax/swing/JMenuBar.java 6 Jun 2006 12:53:29 -0000
@@ -515,20 +515,23 @@
* @param condition the focus condition for the binding
* @param pressed true if the key was pressed
* @return true <code>menuElement</code> or one of its children consume
* the event (processKeyBinding returns true for menuElement or one of
* its children).
*/
static boolean processKeyBindingHelper(MenuElement menuElement, KeyStroke ks,
KeyEvent e, int condition,
boolean pressed)
{
+ if (menuElement == null)
+ return false;
+
// First check the menuElement itself, if it's a JComponent
if (menuElement instanceof JComponent
&& ((JComponent) menuElement).processKeyBinding(ks, e, condition,
pressed))
return true;
// If that didn't consume it, check all the children recursively
MenuElement[] children = menuElement.getSubElements();
for (int i = 0; i < children.length; i++)
if (processKeyBindingHelper(children[i], ks, e, condition, pressed))