-
Bug
-
Resolution: Fixed
-
P3
-
1.4.0
-
beta2
-
generic
-
generic
Name: bkR10012 Date: 04/23/2001
Spec. of the class javax.imageio.ImageReader says:
"getDestination
protected static BufferedImage getDestination(ImageReadParam param,
Iterator imageTypes,
int width,
int height)
throws IIOException
.....
Throws:
IIOException - if the ImageTypeSpecifier specified by param
does not match any of the legal ones from imageTypes.
IllegalArgumentException - if the resulting image would have
a width or height less than 1."
But method getDestination throws unexpected exceptions in following cases:
NullPointerException - if imageTypes is null
NoSuchElementException - if imageTypes is empty
ClassCastException - if imageTypes contains value of improper type
IllegalArgumentException - if dimensions (width, height) are too large
See test source and log below.
---------------------------------------- test.java
import javax.imageio.*;
import javax.imageio.spi.*;
import javax.imageio.metadata.*;
import java.util.*;
import java.awt.image.BufferedImage;
import java.io.IOException;
public class test {
public static void main(String argv[]) {
Vector imageTypes = new Vector();
try {
DummyImageReaderImpl.getDestination(null, null, 5, 10);
} catch (Throwable ee) {
System.out.println("Unexpected exception 1: " + ee);
}
try {
DummyImageReaderImpl.getDestination(null, imageTypes.iterator(),
5, 10);
} catch (Throwable ee) {
System.out.println("Unexpected exception 2: " + ee);
}
imageTypes.add("abc");
try {
DummyImageReaderImpl.getDestination(null, imageTypes.iterator(),
5, 10);
} catch (Throwable ee) {
System.out.println("Unexpected exception 3: " + ee);
}
imageTypes.clear();
ImageTypeSpecifier its = ImageTypeSpecifier.createFromBufferedImageType
(BufferedImage.TYPE_INT_RGB);
imageTypes.add(its);
try {
DummyImageReaderImpl.getDestination(null,
imageTypes.iterator(),
Integer.MAX_VALUE,
Integer.MAX_VALUE);
} catch (Throwable ee) {
System.out.println("Unexpected exception 4: " + ee);
}
}
}
class DummyImageReaderImpl extends ImageReader {
public DummyImageReaderImpl(ImageReaderSpi originatingProvider) {
super(originatingProvider);
}
public static BufferedImage getDestination(ImageReadParam param,
Iterator imageTypes,
int width,
int height) throws IIOException {
return ImageReader.getDestination(param, imageTypes, width, height);
}
public int getNumImages(boolean allowSearch) throws IOException {return 1;}
public int getWidth(int imageIndex) throws IOException {return 1;}
public int getHeight(int imageIndex) throws IOException {return 1;}
public Iterator getImageTypes(int imageIndex)
throws IOException {return null;}
public IIOMetadata getStreamMetadata() throws IOException {return null;}
public IIOMetadata getImageMetadata(int imageIndex)
throws IOException {return null;}
public BufferedImage read(int imageIndex, ImageReadParam param)
throws IOException {return null;}
}
----------------------------------------
% java -version
java version "1.4.0-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta-b61)
Java HotSpot(TM) Client VM (build 1.4.0-beta-b61, mixed mode)
% java test
Unexpected exception 1: java.lang.NullPointerException
Unexpected exception 2: java.util.NoSuchElementException
Unexpected exception 3: java.lang.ClassCastException: java.lang.String
Unexpected exception 4: java.lang.IllegalArgumentException: Dimensions
(width=2147483647 height=2147483647) are too large
----------------------------------------
This bug causes failure of the new JCK test
api/javax_imageio/ImageReader/index.html#getDestination
======================================================================