<Swing Dev> [10] Review Request: JDK-7108280 : JList.getSelectedValuesList fails if JList.setSelectionInterval larger than list

Pankaj Bansal pankaj.b.bansal at oracle.com
Fri Dec 1 09:31:35 UTC 2017


Hi All,

 

Please review the fix.

 

Bug:

https://bugs.openjdk.java.net/browse/JDK-7108280

 

Webrev:

http://cr.openjdk.java.net/~pbansal/7108280/webrev.00/

 

Issue:

JList.getSelectedValuesList crashes if the JList.setSelectionInterval or JList.addSelectionInterval had been called earlier with interval having lead greater than the size of List

 

Fix:

Made changes in JList.getSelectedValuesList to check the if the max selection index is greater than the actual size of the List. If yes, the max is changed to last element index of List.

 

Note:

It makes sense to change the behavior of JList.setSelectionInterval or JList.addSelectionInterval to not allow to set the selection with interval having indices not present in the list. But it will change the behavior of this API and will result in failure of 2 JCK tests. 

Also, we will still have to put checks inside the JList.getSelectedValuesList as the selection can be changed by setting selection interval on DefualtListSelectionModel and there is no way to check if the supplied interval range actually exist in the List inside DefualtListSelectionModel.

 

If changing the JList.setSelectionInterval or JList.addSelectionInterval is possible, the potential fix can be following webrev.

http://cr.openjdk.java.net/~pbansal/7108280/webrev.002/

 

 

Regards,

Pankaj Bansal

 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/swing-dev/attachments/20171201/1927ea54/attachment.html>


More information about the swing-dev mailing list