JDK-6657923 : NullPointerException at SynthArrowButtonUI
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 6u10
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2008-01-31
  • Updated: 2011-02-16
  • Resolved: 2008-06-09
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 6
6u10 b26Fixed
Related Reports
Relates :  
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 is a regression introduced by Nimbus. Simply needs to check for null parent before walking up the heirarchy.
21-05-2008

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.
02-04-2008

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
06-02-2008