JDK-4962642 : REGRESSION: JTabbedPane thorows ArrayIndexOutOfBoundsException
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 5.0
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • OS:
    linux,linux_redhat_9.0,solaris_9,windows_xp linux,linux_redhat_9.0,solaris_9,windows_xp
  • CPU: x86,sparc
  • Submitted: 2003-12-03
  • Updated: 2005-04-26
  • Resolved: 2004-03-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.
Other
5.0 b43Fixed
Related Reports
Duplicate :  
Duplicate :  
Relates :  
Description
 Platform	TurboLinux8.0
JDK		j2sdk1.5.0 b29
Locale		ja, C

To reproduce;
 $ java JTabbedPaneTest
 On GUI, do as follows;
  View -> Placement -> Left (, Bottom, or Right)
  Test -> Auto

Test programs are attached.

Below is the output;

--- insertTab()
--- getTitleAt()
 [0] = tab_string
 [1] = create
 [2] = open
 [3] = save
 [4] = new_tab
 [5] = new_tab
 [6] = new_tab
 [7] = copy
 [8] = paste
 [9] = cut
--- setTitleAt()
--- indexOfTab()
java.lang.ArrayIndexOutOfBoundsException: 9
        at javax.swing.plaf.basic.BasicTabbedPaneUI.tabForCoordinate(BasicTabbedPaneUI.java:1267)
        at javax.swing.plaf.basic.BasicTabbedPaneUI.setRolloverTab(BasicTabbedPaneUI.java:485)
        at javax.swing.plaf.basic.BasicTabbedPaneUI.access$1100(BasicTabbedPaneUI.java:35)
        at javax.swing.plaf.basic.BasicTabbedPaneUI$Handler.mouseEntered(BasicTabbedPaneUI.java:3176)
        at java.awt.AWTEventMulticaster.mouseEntered(AWTEventMulticaster.java:241)
        at java.awt.Component.processMouseEvent(Component.java:5475)
        at javax.swing.JComponent.processMouseEvent(JComponent.java:3037)
        at java.awt.Component.processEvent(Component.java:5231)
        at java.awt.Container.processEvent(Container.java:1987)
        at java.awt.Component.dispatchEventImpl(Component.java:3929)
        at java.awt.Container.dispatchEventImpl(Container.java:2045)
        at java.awt.Component.dispatchEvent(Component.java:3777)
        at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4196)
        at java.awt.LightweightDispatcher.trackMouseEnterExit(Container.java:4027)
        at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3884)
        at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3832)
        at java.awt.Container.dispatchEventImpl(Container.java:2031)
        at java.awt.Window.dispatchEventImpl(Window.java:1749)
        at java.awt.Component.dispatchEvent(Component.java:3777)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
        at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:231)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)


I've tried this test on several releases in TurboLinux8 & RedHat9.0 to see in which releases the bug reproduces.
Below are the results.
 Turbo	1.5.0_b29	fail
  	1.5.0_b25	fail
 	1.5.0_b24	ok
  	1.4.2_FCS	ok
 RedHat	1.5.0_b29	fail
  	1.5.0_b25	fail
  	1.5.0_b24	ok

This bug is reproducible on both ja and C locale.


###@###.### 2003-12-03

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: tiger-beta2 FIXED IN: tiger-beta2 INTEGRATED IN: tiger-b43 tiger-beta2 VERIFIED IN: tiger-beta2
14-06-2004

EVALUATION tabForCoordinate uses the tab count for it's loop, but references the rect array. For some reason these arrays are not the same length which may indicate a problem somewhere else in the code. Though we should probably add a check to ensure that we don't loop over the size of the rect array. ###@###.### 2003-12-08 Name: sh120115 Date: 03/03/2004 This problem was introduced when the mouseEntered method in BasicTabbedPaneUI.handler was changed to call a setRolloverTab version that doesn't validate the layout. This change was necessary to prevent a bug where a mouse movement over the tabs would cause a re-layout and make things jump around. Unfortunately, in this case what happens is the following: - A menu item is selected that adds a new tab (and a revalidate is scheduled) - The menu is dismissed, thereby leaving the mouse over the tab area - The tab area received a mouseEntered event and tries to figure out which tab the mouse is over - Since the tab array has not yet been re-calculated, the exception occurs. I had a conversation with ###@###.### and his suggestion was something to the effect of: - Have some way to internally set/get whether or not the tab array is dirty - Return -1 from tabForCoordinate if the array is dirty - Reset the dirty state when the tab array is recalculated ###@###.### 2004-03-03 ====================================================================== As Shannon said the following changes will be done: BasicTabbedPaneUI will get a isRunsDirty field. If isRunsDirty is true tabForCoordinate will return -1. isRunsDirty will be set true when a component is added/removed and set to false when layout happens. ###@###.### 2004-03-04
04-03-2004