-
Bug
-
Resolution: Fixed
-
P3
-
1.4.0
-
beta2
-
generic
-
generic
Name: vrR10176 Date: 05/30/2001
Api spec (jdk1.4.0beta-b65) says about constructor of class
javax.imageio.plugins.jpeg.JPEGHuffmanTable:
"public JPEGHuffmanTable(short[] lengths, short[] values)
Creates a Huffman table and initializes it. The input arrays are copied.
Parameters:
lengths - an array of shorts where lengths[k-1] is equal to the
number of values with corresponding codes of length k bits.
values - an array of shorts containing the values in order of
increasing code length.
Throws:
IllegalArgumentException - if lengths or values are null, the length
of lengths is greater than 16, the length of values is greater than 256,
or if any value in lengths or values is less than zero."
But the constructor throws unexpected IllegalArgumentException, when
for example lengths set to {3} and values set to {1,2,3}. These
argumentes are not null, the length of lengths is 1, the length of
values is 3, all values in lengths and values are greater than zero.
This bug causes failure of new JCK test:
api/javax_imageio/plugins/jpeg/JPEGHuffmanTable/index.html#Ctor
To reproduce the issue execute the following test.
------------------------ test.java ------------------------
import javax.imageio.plugins.jpeg.JPEGHuffmanTable;
public class test {
public static void main(String[] argv) {
try {
JPEGHuffmanTable jpegHuffmanTable = new JPEGHuffmanTable(new short[]{3},
new short[]{1,2,3});
System.out.println("Test passed");
} catch (IllegalArgumentException e) {
System.out.println("Test failed with " + e);
System.out.println("No exception was expected");
}
}
}
------------ Logs ------------------------------------------
$ java -version
java version "1.4.0-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta-b65)
Java HotSpot(TM) Client VM (build 1.4.0-beta-b65, mixed mode)
$ javac test.java
$ java test
Test failed with java.lang.IllegalArgumentException: Invalid Huffman table provided, lengths are incorrect.
No exception was expected
-----------------------------------------------
======================================================================