United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-7037283 JMenuItem with null text can cause NPE
JDK-7037283 : JMenuItem with null text can cause NPE

Details
Type:
Bug
Submit Date:
2011-04-17
Status:
Closed
Updated Date:
2012-09-06
Project Name:
JDK
Resolved Date:
2011-05-04
Component:
client-libs
OS:
linux
Sub-Component:
javax.swing
CPU:
x86
Priority:
P4
Resolution:
Cannot Reproduce
Affected Versions:
7
Fixed Versions:

Related Reports

Sub Tasks

Description
FULL PRODUCT VERSION :
java version "1.7.0-ea"
Java(TM) SE Runtime Environment (build 1.7.0-ea-b138)
Java HotSpot(TM) Client VM (build 21.0-b08, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Linux localhost 2.6.31-18-generic #55-Ubuntu SMP Fri Jan 8 14:55:26 UTC 2010 i686 GNU/Linux


EXTRA RELEVANT SYSTEM CONFIGURATION :
KDE, Nimbus Look  and Feel

A DESCRIPTION OF THE PROBLEM :
A JMenuItem with null text can cause NullPointerException in some situations.
It seems that MenuItemLayoutHelper.getLeftExtraWidth passes a null text
to the SwingUtilities2.getLeftSideBearing.

REGRESSION.  Last worked in version 6u24


ERROR MESSAGES/STACK TRACES THAT OCCUR :
java.lang.NullPointerException
	at sun.swing.SwingUtilities2.getLeftSideBearing(SwingUtilities2.java:274)
	at sun.swing.MenuItemLayoutHelper.getLeftExtraWidth(MenuItemLayoutHelper.java:162)
	at sun.swing.MenuItemLayoutHelper.calcExtraWidths(MenuItemLayoutHelper.java:158)
	at sun.swing.MenuItemLayoutHelper.reset(MenuItemLayoutHelper.java:148)
	at javax.swing.plaf.synth.SynthMenuItemLayoutHelper.<init>(SynthMenuItemLayoutHelper.java:119)
	at javax.swing.plaf.synth.SynthGraphicsUtils.getPreferredMenuItemSize(SynthGraphicsUtils.java:434)
	at javax.swing.plaf.synth.SynthMenuItemUI.getPreferredMenuItemSize(SynthMenuItemUI.java:218)
	at javax.swing.plaf.basic.BasicMenuItemUI.getPreferredSize(BasicMenuItemUI.java:367)

REPRODUCIBILITY :
This bug can be reproduced always.

                                    

Comments
EVALUATION

Cannot reproduce on b138. Basically, number of options is too big. If there still exists an issue described here, let's wait for a code snippet good enough for reproducing this.
                                     
2011-05-04



Hardware and Software, Engineered to Work Together