-
Bug
-
Resolution: Fixed
-
P3
-
1.3.0
-
beta2
-
sparc
-
solaris_2.6
Name: sdC67446 Date: 09/20/99
The method
public void removeEntries(int index, int length)
of class
javax.swing.SizeSequence
does not throw IllegalArgumentException if:
1) 'index' < 0
2) 'index' >= getSizes().length
3) 'length' < 0
4) 0 <= 'index' < getSizes().length and
0 <= 'length' < getSizes().length and
'index'+'length' >= getSizes().length
5) setSizes(..) has not been called before
Currently the method throws implementation related exceptions:
ArrayIndexOutOfBoundsException and NegativeArraySizeException.
The doc says:
--------------------------------------------------
public void insertEntries(int start,
int length,
int value)
Adds a contiguous group of entries to this SizeSequence.
Parameters:
start - the index to be assigned to the first entry in the
group
length - the number of entries in the group
value - the size to be assigned to each new entry
The demo test:
--------------------------------------------------
import javax.swing.SizeSequence;
public class Test {
static void test(int caseno,
SizeSequence ss,
int index,
int length) {
try {
ss.removeEntries(index,length);
} catch (Exception e) {
System.out.println(caseno+") "+e);
}
}
public static void main(String argv[]) {
int[] sizes = {1000, 2000, 3000};
SizeSequence ss = new SizeSequence();
ss.setSizes(sizes);
test(1,ss,-1,7);
ss = new SizeSequence();
ss.setSizes(sizes);
test(2,ss,ss.getSizes().length,7);
ss = new SizeSequence();
ss.setSizes(sizes);
test(3,ss,1,-2);
ss = new SizeSequence();
ss.setSizes(sizes);
test(4,ss,2,2);
ss = new SizeSequence();
test(5,ss,1,1);
}
}
Output:
--------------------------------------------------
1) java.lang.NegativeArraySizeException
2) java.lang.NegativeArraySizeException
3) java.lang.ArrayIndexOutOfBoundsException
4) java.lang.ArrayIndexOutOfBoundsException
5) java.lang.NegativeArraySizeException
--------------------------------------------------
======================================================================