JDK-5053379 : J2SE 1.5 b1 JTable calls ListSelectionModel.setAnchorSelectionIndex(-1)
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 5.0
  • Priority: P2
  • Status: Closed
  • Resolution: Won't Fix
  • OS: windows_2000
  • CPU: x86
  • Submitted: 2004-05-26
  • Updated: 2005-08-16
  • Resolved: 2005-08-16
Related Reports
Relates :  
Relates :  
Description
Name: gm110360			Date: 05/26/2004


FULL PRODUCT VERSION :
java version "1.5.0-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta-b32c)
Java HotSpot(TM) Client VM (build 1.5.0-beta-b32c, mixed mode)

A DESCRIPTION OF THE PROBLEM :
In J2SE 1.5b1 JTable.checkLeadAnchor() calls interface methods with an undocumented argument:
ListSelectionModel.setAnchorSelectionIndex(-1)
ListSelectionModel.setLeadSelectionIndex(-1)

In J2SE 1.4.2 and prior, these two methods are never called with the argument -1. The ListSelectionModel interface does not require these methods to support being called with the argument -1. Therefore migrating from J2SE 1.4.2 to J2SE 1.5, my implementation of ListSelectionModel broke violently. I assume that other custom implementations of ListSelectionModel will have similar problems when used with J2SE 1.5.

The simple workaround is to call clearSelection() instead of setAnchorSelectionIndex() and setLeadSelectionIndex().


REPRODUCIBILITY :
This bug can be reproduced always.
(Incident Review ID: 275173) 
======================================================================

Comments
EVALUATION In order to fix 4976239, checkLeadAnchor() will be removed. This will address this parcticular bug. However, note that it is NOT against the specification for ListSelectionModel to be called with -1. There are other places in Swing in 6.0 that call the selection model with -1. These will not be changed (as these calls are needed to clear the lead and anchor) and it is highly recommended that the submitter be prepared to deal with -1 in their code.
16-08-2005

CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: dragon mustang
25-09-2004

EVALUATION The fix that introduced this problem was a very favorable fix as it keeps selection models in synch with the table models. Unfortunately it seems to be causing some backward-compatibility issues. For this reason, I'll need to have another look and see about re-working the logic. ###@###.### 2004-06-02 See also 4976239. ###@###.### 2004-07-22
02-06-2004