United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-6657923 NullPointerException at SynthArrowButtonUI
JDK-6657923 : NullPointerException at SynthArrowButtonUI

Details
Type:
Bug
Submit Date:
2008-01-31
Status:
Resolved
Updated Date:
2011-02-16
Project Name:
JDK
Resolved Date:
2008-06-09
Component:
client-libs
OS:
windows_xp
Sub-Component:
javax.swing
CPU:
x86
Priority:
P3
Resolution:
Fixed
Affected Versions:
6u10
Fixed Versions:
6u10 (b26)

Related Reports
Relates:

Sub Tasks

Description
FULL PRODUCT VERSION :
1.6.0_10-ea-fastdebug

ADDITIONAL OS VERSION INFORMATION :
Windows XP SP3

A DESCRIPTION OF THE PROBLEM :
NullPointerException appears if an arrow button has no parent.
StackTrace:

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
        at javax.swing.plaf.synth.SynthArrowButton$SynthArrowButtonUI.getPreferredSize(SynthArrowButton.java:105)
        at javax.swing.JComponent.getPreferredSize(JComponent.java:1632)
        at de.javasoft.plaf.synthetica.StyleFactory.getStyle(StyleFactory.java:286)
        at de.javasoft.plaf.synthetica.StyleFactory.getStyle(StyleFactory.java:160)
        at javax.swing.plaf.synth.SynthLookAndFeel.getStyle(SynthLookAndFeel.java:211)
        at javax.swing.plaf.synth.SynthLookAndFeel.updateStyle(SynthLookAndFeel.java:267)
        at javax.swing.plaf.synth.SynthButtonUI.updateStyle(SynthButtonUI.java:53)
        at javax.swing.plaf.synth.SynthButtonUI.propertyChange(SynthButtonUI.java:442)
        at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:339)
...






REPRODUCIBILITY :
This bug can be reproduced always.

CUSTOMER SUBMITTED WORKAROUND :
  Bugfix proposal: Add a null check against parent before calling parent.getClientProperty()
Reproducible every time with the attached test case on 
the optimized build on 6u10 (windows, dual cpu system).

java.lang.NullPointerException
        at javax.swing.plaf.synth.SynthArrowButton$SynthArrowButtonUI.getPreferredSize(Unknown Source)
        at javax.swing.JComponent.getPreferredSize(Unknown Source)
        at SynthArrowButtonTest$StyleFactory.getStyle(SynthArrowButtonTest.java:70)
        at javax.swing.plaf.synth.SynthLookAndFeel.getStyle(Unknown Source)
        at javax.swing.plaf.synth.SynthLookAndFeel.updateStyle(Unknown Source)
        at javax.swing.plaf.synth.SynthButtonUI.updateStyle(Unknown Source)
        at javax.swing.plaf.synth.SynthButtonUI.propertyChange(Unknown Source)
        at java.beans.PropertyChangeSupport.firePropertyChange(Unknown Source)
        at java.beans.PropertyChangeSupport.firePropertyChange(Unknown Source)
        at java.awt.Component.firePropertyChange(Unknown Source)
        at java.awt.Component.setName(Unknown Source)
        at javax.swing.plaf.synth.SynthSpinnerUI.createNextButton(Unknown Source)
        at javax.swing.plaf.basic.BasicSpinnerUI.installUI(Unknown Source)
        at javax.swing.JComponent.setUI(Unknown Source)
        at javax.swing.JSpinner.setUI(Unknown Source)
        at javax.swing.JSpinner.updateUI(Unknown Source)
        at javax.swing.JSpinner.<init>(Unknown Source)
        at javax.swing.JSpinner.<init>(Unknown Source)
        at SynthArrowButtonTest.<init>(SynthArrowButtonTest.java:47)
        at SynthArrowButtonTest$1.run(SynthArrowButtonTest.java:22)
        at java.awt.event.InvocationEvent.dispatch(Unknown Source)
        at java.awt.EventQueue.dispatchEvent(Unknown Source)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
        at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at java.awt.EventDispatchThread.run(Unknown Source)
More info in this thread: http://forums.java.net/jive/thread.jspa?messageID=267364

                                    

Comments
EVALUATION

This statement
"The exception is only reproducible with fast-debug build. I can reproduce the issue on XP SP2 with 6uN-b11 fast-debug, but not 6uN-b11."
implies that this is the threading problem

The most possible reason of the problem is accessing Swing 
outside Event Dispatch Thread

We ask submitter to make sure that he creates and uses all Swing code
from EventDispatchThread, 
it might be checked with help of SwingUtilities.isEventDispatchThread() method
                                     
2008-02-06
EVALUATION

The regression is introduced by the fix for
  6604357: Nimbus L&F: Add componet customization via ClientProperties
in the following code added with delta 1.19:
            JComponent parent = (JComponent)context.getComponent().getParent();
            if (!(parent instanceof JComboBox)){
*                String scaleKey = (String)parent.getClientProperty("JComponent.sizeVariant");

The NPE is thrown at line *) - apparently parent is null there.
                                     
2008-04-02
EVALUATION

This is a regression introduced by Nimbus. Simply needs to check for null parent before walking up the heirarchy.
                                     
2008-05-21



Hardware and Software, Engineered to Work Together