JDK-8152419 : JColorChooser throws Exception
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 8,9
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_7
  • CPU: x86_64
  • Submitted: 2016-03-22
  • Updated: 2016-09-22
  • Resolved: 2016-06-15
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 9
9 b127Fixed
Description
FULL PRODUCT VERSION :


A DESCRIPTION OF THE PROBLEM :
When border insets of JFormattedTextField exceeds a specific number a NegativeArraySizeException is thrown from javax.swing.colorchooser.DiagramComponent

REGRESSION.  Last worked in version 7u76

ADDITIONAL REGRESSION INFORMATION: 
It looks like the issue was introduced with the new ColorChooser of Java 7.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Execute test below and select HSV, HSL, RGB or CMYK tab.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Content of the selected tab should appear.
ACTUAL -
Exception is thrown - related content does not appear.

ERROR MESSAGES/STACK TRACES THAT OCCUR :
Exception in thread "AWT-EventQueue-0" java.lang.NegativeArraySizeException
        at javax.swing.colorchooser.DiagramComponent.paintComponent(Unknown Source)
        at javax.swing.JComponent.paint(Unknown Source)
        at javax.swing.JComponent.paintChildren(Unknown Source)
        at javax.swing.JComponent.paint(Unknown Source)
        at javax.swing.colorchooser.AbstractColorChooserPanel.paint(Unknown Source)
        at javax.swing.JComponent.paintChildren(Unknown Source)
        at javax.swing.JComponent.paint(Unknown Source)
        at javax.swing.JComponent.paintChildren(Unknown Source)
        at javax.swing.JComponent.paint(Unknown Source)
        at javax.swing.JComponent.paintChildren(Unknown Source)
        at javax.swing.JComponent.paint(Unknown Source)
        at javax.swing.JComponent.paintToOffscreen(Unknown Source)
        at javax.swing.RepaintManager$PaintManager.paintDoubleBuffered(Unknown Source)
        at javax.swing.RepaintManager$PaintManager.paint(Unknown Source)
        at javax.swing.RepaintManager.paint(Unknown Source)
        at javax.swing.JComponent._paintImmediately(Unknown Source)
        at javax.swing.JComponent.paintImmediately(Unknown Source)
        at javax.swing.RepaintManager$4.run(Unknown Source)
        at javax.swing.RepaintManager$4.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
        at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
        at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
        at javax.swing.RepaintManager.prePaintDirtyRegions(Unknown Source)
        at javax.swing.RepaintManager.access$1200(Unknown Source)
        at javax.swing.RepaintManager$ProcessingRunnable.run(Unknown Source)
        at java.awt.event.InvocationEvent.dispatch(Unknown Source)
        at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
        at java.awt.EventQueue.access$500(Unknown Source)
        at java.awt.EventQueue$3.run(Unknown Source)
        at java.awt.EventQueue$3.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(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.pumpEventsForFilter(Unknown Source)
        at java.awt.WaitDispatchSupport$2.run(Unknown Source)
        at java.awt.WaitDispatchSupport$4.run(Unknown Source)
        at java.awt.WaitDispatchSupport$4.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.awt.WaitDispatchSupport.enter(Unknown Source)
        at java.awt.Dialog.show(Unknown Source)
        at javax.swing.ColorChooserDialog.show(Unknown Source)
        at javax.swing.JColorChooser.showDialog(Unknown Source)
        at test.dialog.ColorChooserTest$1.run(ColorChooserTest.java:23)
        at java.awt.event.InvocationEvent.dispatch(Unknown Source)
        at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
        at java.awt.EventQueue.access$500(Unknown Source)
        at java.awt.EventQueue$3.run(Unknown Source)
        at java.awt.EventQueue$3.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(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)

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
public class ColorChooserTest
{
  public static void main(String[] args) throws Exception
  {
    SwingUtilities.invokeLater(new Runnable()
    {
      public void run()
      {
        UIManager.put("FormattedTextField.border", new EmptyBorder(0,10,0,10));
        JColorChooser.showDialog(null, "Test", Color.BLUE);        
      }
    });
  }
}
---------- END SOURCE ----------


Comments
not a regression for 9 since introduced even in 8
04-04-2016

Reproducible in JDK9
28-03-2016

1) Run the linked test case and select HSV, HSL, RGB or CMYK tab. 7u80: OK 8: FAIL 8u74: FAIL 9 ea b100: FAIL The content of the selected tab appears fine with JDK 7u80, but failed with "Exception in thread "AWT-EventQueue-0" java.lang.NegativeArraySizeException" This is a regression with JDK 8 and onwards. Output with 8u74: ======================================================================================== Exception in thread "AWT-EventQueue-0" java.lang.NegativeArraySizeException at javax.swing.colorchooser.DiagramComponent.paintComponent(DiagramComponent.java:69) at javax.swing.JComponent.paint(JComponent.java:1056) at javax.swing.JComponent.paintChildren(JComponent.java:889) at javax.swing.JComponent.paint(JComponent.java:1065) at javax.swing.colorchooser.AbstractColorChooserPanel.paint(AbstractColorChooserPanel.java:205) at javax.swing.JComponent.paintChildren(JComponent.java:889) at javax.swing.JComponent.paint(JComponent.java:1065) at javax.swing.JComponent.paintChildren(JComponent.java:889) .................................. ................................... .................................... ========================================================================================
22-03-2016