Details
-
Bug
-
Resolution: Fixed
-
P3
-
6u18
-
b110
-
x86
-
windows_xp
Description
java version "1.6.0_18"
Java(TM) SE Runtime Environment (build 1.6.0_18-b07)
Java HotSpot(TM) Client VM (build 16.0-b13, mixed mode, sharing)
Does this problem occur on J2SE 5.0.x or 6.0? Yes / No (pick one)
Yes
Operating System Configuration Information (be specific):
Client: Windows XP
Bug Description:
JTabbedPane throws ArrayIndexOutOfBoundsException sometimes
This is a duplicate of 4873983.
We have just seen this bug happen again in 1.6.0_18.
Here is the stack trace:
java.lang.ArrayIndexOutOfBoundsException: 0
at javax.swing.plaf.basic.BasicTabbedPaneUI$ScrollableTabSupport.updateView(BasicTabbedPaneUI.java:3348)
at javax.swing.plaf.basic.BasicTabbedPaneUI$ScrollableTabSupport.stateChanged(BasicTabbedPaneUI.java:3331)
at javax.swing.JViewport.fireStateChanged(JViewport.java:1384)
at javax.swing.JViewport$ViewListener.componentResized(JViewport.java:1302)
at java.awt.Component.processComponentEvent(Component.java:6089)
at java.awt.Component.processEvent(Component.java:6043)
at java.awt.Container.processEvent(Container.java:2041)
at java.awt.Component.dispatchEventImpl(Component.java:4630)
at java.awt.Container.dispatchEventImpl(Container.java:2099)
at java.awt.Component.dispatchEvent(Component.java:4460)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
The bug was closed without getting fixed before and still exists in 1.6.0_18.
Note that all changes to the TabbedPane are done within the event dispatch thread.
See bug 4873983 for further information including my comments written in that bug report.
This is not an easy bug to workaround.
The JDK and OS are:
java version "1.6.0_18"
Java(TM) SE Runtime Environment (build 1.6.0_18-b07)
Java HotSpot(TM) Client VM (build 16.0-b13, mixed mode, sharing)
and
Operating System Configuration Information (be specific):
Client: Windows XP
The code below was able to reproduce the problem on jdk1.4.2 about 1 in 10 times.
Using the actual code the problem didn't occur for a very long time and then occurred again on jdk 1.6.0_18.
This problem does not happen very often, and so coming up with a small test case that reproduces the problem every time is very difficult.
As mentioned everything is done within the Swing Thread.
The problem is that the stack trace leading up to
javax.swing.plaf.basic.BasicTabbedPaneUI$ScrollableTabSupport.stateChanged(BasicTabbedPaneUI.java:2893) can be called after addTab and before assureRectsCreated with the updated tab count. For some reason assureRectsCreated has been scattered through code so that most of the time it does get called (like from repaint events from memory), which is why the problem hardly ever happens.
As mentioned you could make a simple fix by adding a call to assureRectsCreated(int tabCount) straight after int tabCount = tabPane.getTabCount(); in public void stateChanged(ChangeEvent e).
Java(TM) SE Runtime Environment (build 1.6.0_18-b07)
Java HotSpot(TM) Client VM (build 16.0-b13, mixed mode, sharing)
Does this problem occur on J2SE 5.0.x or 6.0? Yes / No (pick one)
Yes
Operating System Configuration Information (be specific):
Client: Windows XP
Bug Description:
JTabbedPane throws ArrayIndexOutOfBoundsException sometimes
This is a duplicate of 4873983.
We have just seen this bug happen again in 1.6.0_18.
Here is the stack trace:
java.lang.ArrayIndexOutOfBoundsException: 0
at javax.swing.plaf.basic.BasicTabbedPaneUI$ScrollableTabSupport.updateView(BasicTabbedPaneUI.java:3348)
at javax.swing.plaf.basic.BasicTabbedPaneUI$ScrollableTabSupport.stateChanged(BasicTabbedPaneUI.java:3331)
at javax.swing.JViewport.fireStateChanged(JViewport.java:1384)
at javax.swing.JViewport$ViewListener.componentResized(JViewport.java:1302)
at java.awt.Component.processComponentEvent(Component.java:6089)
at java.awt.Component.processEvent(Component.java:6043)
at java.awt.Container.processEvent(Container.java:2041)
at java.awt.Component.dispatchEventImpl(Component.java:4630)
at java.awt.Container.dispatchEventImpl(Container.java:2099)
at java.awt.Component.dispatchEvent(Component.java:4460)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
The bug was closed without getting fixed before and still exists in 1.6.0_18.
Note that all changes to the TabbedPane are done within the event dispatch thread.
See bug 4873983 for further information including my comments written in that bug report.
This is not an easy bug to workaround.
The JDK and OS are:
java version "1.6.0_18"
Java(TM) SE Runtime Environment (build 1.6.0_18-b07)
Java HotSpot(TM) Client VM (build 16.0-b13, mixed mode, sharing)
and
Operating System Configuration Information (be specific):
Client: Windows XP
The code below was able to reproduce the problem on jdk1.4.2 about 1 in 10 times.
Using the actual code the problem didn't occur for a very long time and then occurred again on jdk 1.6.0_18.
This problem does not happen very often, and so coming up with a small test case that reproduces the problem every time is very difficult.
As mentioned everything is done within the Swing Thread.
The problem is that the stack trace leading up to
javax.swing.plaf.basic.BasicTabbedPaneUI$ScrollableTabSupport.stateChanged(BasicTabbedPaneUI.java:2893) can be called after addTab and before assureRectsCreated with the updated tab count. For some reason assureRectsCreated has been scattered through code so that most of the time it does get called (like from repaint events from memory), which is why the problem hardly ever happens.
As mentioned you could make a simple fix by adding a call to assureRectsCreated(int tabCount) straight after int tabCount = tabPane.getTabCount(); in public void stateChanged(ChangeEvent e).
Attachments
Issue Links
- relates to
-
JDK-4873983 JTabbedPane throws ArrayIndexOutOfBoundsException sometimes
- Closed