提交 9d18b9ea 编写于 作者: B bae

6656625:...

6656625: ImageReaderSpi.STANDARD_INPUT_TYPE/ImageWriterSpi.STANDARD_OUTPUT_TYPE are mutable static (findbugs)
Reviewed-by: prr
上级 908a2038
......@@ -51,7 +51,7 @@ public class BMPImageReaderSpi extends ImageReaderSpi {
entensions,
mimeType,
"com.sun.imageio.plugins.bmp.BMPImageReader",
STANDARD_INPUT_TYPE,
new Class[] { ImageInputStream.class },
writerSpiNames,
false,
null, null, null, null,
......
......@@ -32,6 +32,7 @@ import java.awt.image.SinglePixelPackedSampleModel;
import javax.imageio.spi.ImageWriterSpi;
import javax.imageio.spi.ServiceRegistry;
import javax.imageio.spi.IIORegistry;
import javax.imageio.stream.ImageOutputStream;
import javax.imageio.ImageWriter;
import javax.imageio.ImageTypeSpecifier;
import javax.imageio.IIOException;
......@@ -55,7 +56,7 @@ public class BMPImageWriterSpi extends ImageWriterSpi {
entensions,
mimeType,
"com.sun.imageio.plugins.bmp.BMPImageWriter",
STANDARD_OUTPUT_TYPE,
new Class[] { ImageOutputStream.class },
readerSpiNames,
false,
null, null, null, null,
......
......@@ -60,7 +60,7 @@ public class GIFImageReaderSpi extends ImageReaderSpi {
suffixes,
MIMETypes,
readerClassName,
STANDARD_INPUT_TYPE,
new Class[] { ImageInputStream.class },
writerSpiNames,
true,
GIFStreamMetadata.nativeMetadataFormatName,
......
......@@ -31,6 +31,7 @@ import java.util.Locale;
import javax.imageio.ImageTypeSpecifier;
import javax.imageio.ImageWriter;
import javax.imageio.spi.ImageWriterSpi;
import javax.imageio.stream.ImageOutputStream;
import com.sun.imageio.plugins.common.PaletteBuilder;
public class GIFImageWriterSpi extends ImageWriterSpi {
......@@ -59,7 +60,7 @@ public class GIFImageWriterSpi extends ImageWriterSpi {
suffixes,
MIMETypes,
writerClassName,
STANDARD_OUTPUT_TYPE,
new Class[] { ImageOutputStream.class },
readerSpiNames,
true,
GIFWritableStreamMetadata.NATIVE_FORMAT_NAME,
......
......@@ -46,7 +46,7 @@ public class JPEGImageReaderSpi extends ImageReaderSpi {
JPEG.suffixes,
JPEG.MIMETypes,
"com.sun.imageio.plugins.jpeg.JPEGImageReader",
STANDARD_INPUT_TYPE,
new Class[] { ImageInputStream.class },
writerSpiNames,
true,
JPEG.nativeStreamMetadataFormatName,
......
......@@ -28,6 +28,7 @@ package com.sun.imageio.plugins.jpeg;
import javax.imageio.spi.ImageWriterSpi;
import javax.imageio.spi.ServiceRegistry;
import javax.imageio.spi.IIORegistry;
import javax.imageio.stream.ImageOutputStream;
import javax.imageio.ImageWriter;
import javax.imageio.ImageTypeSpecifier;
import javax.imageio.IIOException;
......@@ -49,7 +50,7 @@ public class JPEGImageWriterSpi extends ImageWriterSpi {
JPEG.suffixes,
JPEG.MIMETypes,
"com.sun.imageio.plugins.jpeg.JPEGImageWriter",
STANDARD_OUTPUT_TYPE,
new Class[] { ImageOutputStream.class },
readerSpiNames,
true,
JPEG.nativeStreamMetadataFormatName,
......
......@@ -60,7 +60,7 @@ public class PNGImageReaderSpi extends ImageReaderSpi {
suffixes,
MIMETypes,
readerClassName,
STANDARD_INPUT_TYPE,
new Class[] { ImageInputStream.class },
writerSpiNames,
false,
null, null,
......
......@@ -34,6 +34,7 @@ import javax.imageio.ImageTypeSpecifier;
import javax.imageio.metadata.IIOMetadataFormat;
import javax.imageio.metadata.IIOMetadataFormatImpl;
import javax.imageio.spi.ImageWriterSpi;
import javax.imageio.stream.ImageOutputStream;
public class PNGImageWriterSpi extends ImageWriterSpi {
......@@ -61,7 +62,7 @@ public class PNGImageWriterSpi extends ImageWriterSpi {
suffixes,
MIMETypes,
writerClassName,
STANDARD_OUTPUT_TYPE,
new Class[] { ImageOutputStream.class },
readerSpiNames,
false,
null, null,
......
......@@ -51,7 +51,7 @@ public class WBMPImageReaderSpi extends ImageReaderSpi {
entensions,
mimeType,
"com.sun.imageio.plugins.wbmp.WBMPImageReader",
STANDARD_INPUT_TYPE,
new Class[] { ImageInputStream.class },
writerSpiNames,
true,
null, null, null, null,
......
......@@ -28,6 +28,7 @@ package com.sun.imageio.plugins.wbmp;
import javax.imageio.spi.ImageWriterSpi;
import javax.imageio.spi.ServiceRegistry;
import javax.imageio.spi.IIORegistry;
import javax.imageio.stream.ImageOutputStream;
import javax.imageio.ImageWriter;
import javax.imageio.ImageTypeSpecifier;
import javax.imageio.IIOException;
......@@ -54,7 +55,7 @@ public class WBMPImageWriterSpi extends ImageWriterSpi {
entensions,
mimeType,
"com.sun.imageio.plugins.wbmp.WBMPImageWriter",
STANDARD_OUTPUT_TYPE,
new Class[] { ImageOutputStream.class },
readerSpiNames,
true,
null, null, null, null,
......
......@@ -77,7 +77,10 @@ public abstract class ImageReaderSpi extends ImageReaderWriterSpi {
* A single-element array, initially containing
* <code>ImageInputStream.class</code>, to be returned from
* <code>getInputTypes</code>.
* @deprecated Instead of using this field, directly create
* the equivalent array <code>{ ImageInputStream.class }<code>.
*/
@Deprecated
public static final Class[] STANDARD_INPUT_TYPE =
{ ImageInputStream.class };
......@@ -227,7 +230,11 @@ public abstract class ImageReaderSpi extends ImageReaderWriterSpi {
throw new IllegalArgumentException
("inputTypes.length == 0!");
}
this.inputTypes = (Class[])inputTypes.clone();
this.inputTypes = (inputTypes == STANDARD_INPUT_TYPE) ?
new Class<?>[] { ImageInputStream.class } :
inputTypes.clone();
// If length == 0, leave it null
if (writerSpiNames != null && writerSpiNames.length > 0) {
this.writerSpiNames = (String[])writerSpiNames.clone();
......
......@@ -77,9 +77,12 @@ public abstract class ImageWriterSpi extends ImageReaderWriterSpi {
/**
* A single-element array, initially containing
* <code>ImageInputStream.class</code>, to be returned from
* <code>getInputTypes</code>.
* <code>ImageOutputStream.class</code>, to be returned from
* <code>getOutputTypes</code>.
* @deprecated Instead of using this field, directly create
* the equivalent array <code>{ ImageOutputStream.class }<code>.
*/
@Deprecated
public static final Class[] STANDARD_OUTPUT_TYPE =
{ ImageOutputStream.class };
......@@ -228,7 +231,11 @@ public abstract class ImageWriterSpi extends ImageReaderWriterSpi {
throw new IllegalArgumentException
("outputTypes.length == 0!");
}
this.outputTypes = (Class[])outputTypes.clone();
this.outputTypes = (outputTypes == STANDARD_OUTPUT_TYPE) ?
new Class<?>[] { ImageOutputStream.class } :
outputTypes.clone();
// If length == 0, leave it null
if (readerSpiNames != null && readerSpiNames.length > 0) {
this.readerSpiNames = (String[])readerSpiNames.clone();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册