-
Bug
-
Resolution: Fixed
-
P4
-
6
-
None
-
b53
-
sparc
-
solaris_7
According to the spec, ColorModel.getRGB() could only throw
IllegalArgumentException "if pixel values for this ColorModel are not
conveniently representable as a single int". However, the following program
shows that ArrayIndexOutOfBoundsException is thrown from
IndexColorModel.getRGB():
import java.awt.*;
import java.awt.image.*;
public class IndexColorModelTest {
public static void main(String[] args) {
ColorModel cm = Toolkit.getDefaultToolkit().getColorModel();
if (cm instanceof IndexColorModel) {
int[] pixels = { 0, 1, -1, Integer.MAX_VALUE, Integer.MIN_VALUE,
50, 2467, 72693, -28, -892, -29023};
for (int i = 0; i < pixels.length; i++) {
try {
cm.getRGB(pixels[i]);
} catch (ArrayIndexOutOfBoundsException e) {
System.out.println("ArrayIndexOutOfBoundsException thrown on " + pixels[i]);
}
}
}
}
}
output:
ArrayIndexOutOfBoundsException thrown on -1
ArrayIndexOutOfBoundsException thrown on 2147483647
ArrayIndexOutOfBoundsException thrown on -2147483648
ArrayIndexOutOfBoundsException thrown on 2467
ArrayIndexOutOfBoundsException thrown on 72693
ArrayIndexOutOfBoundsException thrown on -28
ArrayIndexOutOfBoundsException thrown on -892
ArrayIndexOutOfBoundsException thrown on -29023
IllegalArgumentException "if pixel values for this ColorModel are not
conveniently representable as a single int". However, the following program
shows that ArrayIndexOutOfBoundsException is thrown from
IndexColorModel.getRGB():
import java.awt.*;
import java.awt.image.*;
public class IndexColorModelTest {
public static void main(String[] args) {
ColorModel cm = Toolkit.getDefaultToolkit().getColorModel();
if (cm instanceof IndexColorModel) {
int[] pixels = { 0, 1, -1, Integer.MAX_VALUE, Integer.MIN_VALUE,
50, 2467, 72693, -28, -892, -29023};
for (int i = 0; i < pixels.length; i++) {
try {
cm.getRGB(pixels[i]);
} catch (ArrayIndexOutOfBoundsException e) {
System.out.println("ArrayIndexOutOfBoundsException thrown on " + pixels[i]);
}
}
}
}
}
output:
ArrayIndexOutOfBoundsException thrown on -1
ArrayIndexOutOfBoundsException thrown on 2147483647
ArrayIndexOutOfBoundsException thrown on -2147483648
ArrayIndexOutOfBoundsException thrown on 2467
ArrayIndexOutOfBoundsException thrown on 72693
ArrayIndexOutOfBoundsException thrown on -28
ArrayIndexOutOfBoundsException thrown on -892
ArrayIndexOutOfBoundsException thrown on -29023
- relates to
-
JDK-6313119 reconsider IndexColorModel behavior for pixel bits == 3
-
- Open
-