-
Bug
-
Resolution: Fixed
-
P3
-
1.4.0
-
beta2
-
generic
-
generic
Name: bkR10012 Date: 05/08/2001
According to the spec. of the class javax.imageio.ImageWriter
the default implementation throws an UnsupportedOperationException
for almost all unsupported operation.
But for methods replacePixels and endReplacePixels spec says:
"
.....
The default implementation throws an IllegalStateException."
I suppose that behavior of all methods should be similar
and these methods should throw UnsupportedOperationException.
Also spec. says about endWriteEmpty and endInsertEmpty methods:
"
.....
The default implementation throws an UnsupportedOperationException
if the output is non-null. "
But these methods throw unexpected IllegalStateException.
Note also that UnsupportedOperationException is not listed in
the Throws section of the methods spec.
See test source and log below.
---------------------------------------- test.java
import javax.imageio.*;
import javax.imageio.spi.*;
import javax.imageio.metadata.*;
import javax.imageio.stream.MemoryCacheImageOutputStream;
import java.io.IOException;
import java.io.ByteArrayOutputStream;
public class test {
private final static byte[] ba = {};
public static void main(String argv[]) {
ImageWriter iwriter = new DummyImageWriterImpl(null);
MemoryCacheImageOutputStream mcios = new MemoryCacheImageOutputStream
(new ByteArrayOutputStream());
iwriter.setOutput(mcios);
try {
iwriter.endWriteEmpty();
} catch (UnsupportedOperationException e) {
System.out.println("endWriteEmpty: OKAY");
} catch (Throwable ee) {
System.out.println("endWriteEmpty Unexpected exception: " + ee);
}
try {
iwriter.endInsertEmpty();
} catch (UnsupportedOperationException e) {
System.out.println("endInsertEmpty: OKAY");
} catch (Throwable ee) {
System.out.println("endInsertEmpty Unexpected exception: " + ee);
}
}
}
class DummyImageWriterImpl extends ImageWriter {
public DummyImageWriterImpl(ImageWriterSpi originatingProvider) {
super(originatingProvider);
}
public IIOMetadata convertImageMetadata(IIOMetadata inData,
ImageTypeSpecifier imageType,
ImageWriteParam param) {
return null;
}
public IIOMetadata convertStreamMetadata(IIOMetadata inData,
ImageWriteParam param) {
return null;
}
public IIOMetadata getDefaultImageMetadata(ImageTypeSpecifier imageType,
ImageWriteParam param) {
return null;
}
public IIOMetadata getDefaultStreamMetadata(ImageWriteParam param) {
return null;
}
public void write(IIOMetadata streamMetadata,
IIOImage image,
ImageWriteParam param) throws IOException {
return;
}
}
----------------------------------------
% java -version
java version "1.4.0-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta-b63)
Java HotSpot(TM) Client VM (build 1.4.0-beta-b63, mixed mode)
% java test
endWriteEmpty Unexpected exception: java.lang.IllegalStateException: No call to
prepareInsertEmpty!
endInsertEmpty Unexpected exception: java.lang.IllegalStateException: No call to
prepareInsertEmpty!
----------------------------------------
This bug causes failures of the new JCK tests
api/javax_imageio/ImageWriter/index.html#endWriteEmpty
api/javax_imageio/ImageWriter/index.html#endInsertEmpty
======================================================================