-
Bug
-
Resolution: Fixed
-
P4
-
7, 8, 9, 10, 11
-
b07
-
x86
-
generic
FULL PRODUCT VERSION :
java version "1.7.0_01"
Java(TM) SE Runtime Environment (build 1.7.0_01-b08)
Java HotSpot(TM) 64-Bit Server VM (build 21.1-b02, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]
A DESCRIPTION OF THE PROBLEM :
If all elements of a JList are preselected using addSelectionInterval and indices are larger than the list, then getSelectedValuesList() will fail with an OutOfBound exception (note that the deprecated getSelectedValues will fail as well)
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
// Create a JList with 2 elements
DefaultListModel<String> dlm = new DefaultListModel<String>();
list = new JList<String>(dlm);
list.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
dlm.addElement("1");
dlm.addElement("2");
// Set the selection interval too large (3 elements instead of 2)
list.addSelectionInterval(0, 2);
list.getSelectedValuesList()
will trigger java.lang.ArrayIndexOutOfBoundsException: 2 >= 2
at java.util.Vector.elementAt(Vector.java:470)
at javax.swing.DefaultListModel.getElementAt(DefaultListModel.java:89)
at javax.swing.JList.getSelectedValuesList(JList.java:2303)
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Expected all selected elements or an exception at addSelectionInterval saying that the interval was incorrect
ACTUAL -
java.lang.ArrayIndexOutOfBoundsException: 2 >= 2
at java.util.Vector.elementAt(Vector.java:470)
at javax.swing.DefaultListModel.getElementAt(DefaultListModel.java:89)
at javax.swing.JList.getSelectedValuesList(JList.java:2303)
REPRODUCIBILITY :
This bug can be reproduced always.
CUSTOMER SUBMITTED WORKAROUND :
Set the selection interval properly.
java version "1.7.0_01"
Java(TM) SE Runtime Environment (build 1.7.0_01-b08)
Java HotSpot(TM) 64-Bit Server VM (build 21.1-b02, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]
A DESCRIPTION OF THE PROBLEM :
If all elements of a JList are preselected using addSelectionInterval and indices are larger than the list, then getSelectedValuesList() will fail with an OutOfBound exception (note that the deprecated getSelectedValues will fail as well)
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
// Create a JList with 2 elements
DefaultListModel<String> dlm = new DefaultListModel<String>();
list = new JList<String>(dlm);
list.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
dlm.addElement("1");
dlm.addElement("2");
// Set the selection interval too large (3 elements instead of 2)
list.addSelectionInterval(0, 2);
list.getSelectedValuesList()
will trigger java.lang.ArrayIndexOutOfBoundsException: 2 >= 2
at java.util.Vector.elementAt(Vector.java:470)
at javax.swing.DefaultListModel.getElementAt(DefaultListModel.java:89)
at javax.swing.JList.getSelectedValuesList(JList.java:2303)
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Expected all selected elements or an exception at addSelectionInterval saying that the interval was incorrect
ACTUAL -
java.lang.ArrayIndexOutOfBoundsException: 2 >= 2
at java.util.Vector.elementAt(Vector.java:470)
at javax.swing.DefaultListModel.getElementAt(DefaultListModel.java:89)
at javax.swing.JList.getSelectedValuesList(JList.java:2303)
REPRODUCIBILITY :
This bug can be reproduced always.
CUSTOMER SUBMITTED WORKAROUND :
Set the selection interval properly.