Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 6657923
Votes 2
Synopsis NullPointerException at SynthArrowButtonUI
Category java:classes_swing
Reported Against
Release Fixed 6u10(b26)
State 10-Fix Delivered, bug
Priority: 3-Medium
Related Bugs 6604357
Submit Date 31-JAN-2008
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()
Posted Date : 2008-01-31 23:53:55.0

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)
Posted Date : 2008-04-02 16:47:10.0

More info in this thread: http://forums.java.net/jive/thread.jspa?messageID=267364
Posted Date : 2008-04-02 16:49:39.0
Work Around
N/A
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
Posted Date : 2008-02-06 16:57:12.0

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.
Posted Date : 2008-04-02 16:47:10.0

This is a regression introduced by Nimbus. Simply needs to check for null parent before walking up the heirarchy.
Posted Date : 2008-05-21 21:01:12.0
Comments
  
  Include a link with my name & email   

Submitted On 18-FEB-2008
This is not a threading problem - please take a look at the relevant code lines and simply add a null check.


Submitted On 20-MAR-2008
Test case:

public class SynthArrowButtonTest extends JFrame
{
  private static String synthXml = "<synth>" +
  "    <style id=\"all\">" +
  "      <font name=\"Verdana\" size=\"12\"/>" +
  "    </style>" +
  "    <bind style=\"all\" type=\"REGION\" key=\".*\"/>" +
  "</synth>";
  
  public static void main(String[] args)
  {
    EventQueue.invokeLater(new Runnable(){
      public void run()
      {
        try
        {
          new SynthArrowButtonTest();
        }
        catch (Exception e)
        {
          e.printStackTrace();
        }
      }
    });   
  }

  public SynthArrowButtonTest() throws Exception
  {
    InputStream is = new ByteArrayInputStream(synthXml.getBytes("UTF8"));
    SynthLookAndFeel laf = new SynthLookAndFeel(){
      @Override
      public void initialize()
      {
        super.initialize();
        StyleFactory styleFactory = new StyleFactory(getStyleFactory());    
        setStyleFactory(styleFactory);
      }
    };
    laf.load(is, SynthArrowButtonTest.class);
    UIManager.setLookAndFeel(laf);    

    JSpinner sp = new JSpinner();
    add(sp);

    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setSize(new Dimension(400, 300));
    setLocationRelativeTo(null);
    setVisible(true);  
  }

  public static class StyleFactory extends SynthStyleFactory
  {
    private SynthStyleFactory synthStyleFactory;
    
    public StyleFactory(SynthStyleFactory synthStyleFactory)
    {
      this.synthStyleFactory = synthStyleFactory;
    }

    @Override
    public SynthStyle getStyle(JComponent c, Region id)
    {
      String name = c.getName();
      if (id == Region.ARROW_BUTTON && name != null && name.startsWith("Spinner."))
        c.getPreferredSize();  

      return synthStyleFactory.getStyle(c, id);
    }
  }    
}  


Submitted On 17-APR-2008
adanecito
Just curious when this will be fixed. It breaks the use of anyone with skins.


Submitted On 22-MAY-2008
Yanic
Still present on 1.6.0_10-beta-b14 and 1.6.0_10-beta-b23.

Please fix this, you're forcing me to disable my custom L&F on whenever my app detects java 6 update 10 - making a good looking java app ugly.

You committed to supporting any custom L&F in Swing, now stick to it.


Submitted On 24-MAY-2008
adanecito
Hopefully this gets fixed in b25?



PLEASE NOTE: JDK6 is formerly known as Project Mustang