changeset 1500:7b50813648d8

6656625: ImageReaderSpi.STANDARD_INPUT_TYPE/ImageWriterSpi.STANDARD_OUTPUT_TYPE are mutable static (findbugs) Reviewed-by: prr
author bae
date Fri, 08 May 2009 15:38:21 +0400
parents a53a57a3260c
children c6ea5b6c3a8d
files src/share/classes/com/sun/imageio/plugins/bmp/BMPImageReaderSpi.java src/share/classes/com/sun/imageio/plugins/bmp/BMPImageWriterSpi.java src/share/classes/com/sun/imageio/plugins/gif/GIFImageReaderSpi.java src/share/classes/com/sun/imageio/plugins/gif/GIFImageWriterSpi.java src/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageReaderSpi.java src/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageWriterSpi.java src/share/classes/com/sun/imageio/plugins/png/PNGImageReaderSpi.java src/share/classes/com/sun/imageio/plugins/png/PNGImageWriterSpi.java src/share/classes/com/sun/imageio/plugins/wbmp/WBMPImageReaderSpi.java src/share/classes/com/sun/imageio/plugins/wbmp/WBMPImageWriterSpi.java src/share/classes/javax/imageio/spi/ImageReaderSpi.java src/share/classes/javax/imageio/spi/ImageWriterSpi.java
diffstat 12 files changed, 33 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/com/sun/imageio/plugins/bmp/BMPImageReaderSpi.java	Thu May 07 10:44:45 2009 +0200
+++ b/src/share/classes/com/sun/imageio/plugins/bmp/BMPImageReaderSpi.java	Fri May 08 15:38:21 2009 +0400
@@ -51,7 +51,7 @@
               entensions,
               mimeType,
               "com.sun.imageio.plugins.bmp.BMPImageReader",
-              STANDARD_INPUT_TYPE,
+              new Class[] { ImageInputStream.class },
               writerSpiNames,
               false,
               null, null, null, null,
--- a/src/share/classes/com/sun/imageio/plugins/bmp/BMPImageWriterSpi.java	Thu May 07 10:44:45 2009 +0200
+++ b/src/share/classes/com/sun/imageio/plugins/bmp/BMPImageWriterSpi.java	Fri May 08 15:38:21 2009 +0400
@@ -32,6 +32,7 @@
 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 @@
               entensions,
               mimeType,
               "com.sun.imageio.plugins.bmp.BMPImageWriter",
-              STANDARD_OUTPUT_TYPE,
+              new Class[] { ImageOutputStream.class },
               readerSpiNames,
               false,
               null, null, null, null,
--- a/src/share/classes/com/sun/imageio/plugins/gif/GIFImageReaderSpi.java	Thu May 07 10:44:45 2009 +0200
+++ b/src/share/classes/com/sun/imageio/plugins/gif/GIFImageReaderSpi.java	Fri May 08 15:38:21 2009 +0400
@@ -60,7 +60,7 @@
               suffixes,
               MIMETypes,
               readerClassName,
-              STANDARD_INPUT_TYPE,
+              new Class[] { ImageInputStream.class },
               writerSpiNames,
               true,
               GIFStreamMetadata.nativeMetadataFormatName,
--- a/src/share/classes/com/sun/imageio/plugins/gif/GIFImageWriterSpi.java	Thu May 07 10:44:45 2009 +0200
+++ b/src/share/classes/com/sun/imageio/plugins/gif/GIFImageWriterSpi.java	Fri May 08 15:38:21 2009 +0400
@@ -31,6 +31,7 @@
 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 @@
               suffixes,
               MIMETypes,
               writerClassName,
-              STANDARD_OUTPUT_TYPE,
+              new Class[] { ImageOutputStream.class },
               readerSpiNames,
               true,
               GIFWritableStreamMetadata.NATIVE_FORMAT_NAME,
--- a/src/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageReaderSpi.java	Thu May 07 10:44:45 2009 +0200
+++ b/src/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageReaderSpi.java	Fri May 08 15:38:21 2009 +0400
@@ -46,7 +46,7 @@
               JPEG.suffixes,
               JPEG.MIMETypes,
               "com.sun.imageio.plugins.jpeg.JPEGImageReader",
-              STANDARD_INPUT_TYPE,
+              new Class[] { ImageInputStream.class },
               writerSpiNames,
               true,
               JPEG.nativeStreamMetadataFormatName,
--- a/src/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageWriterSpi.java	Thu May 07 10:44:45 2009 +0200
+++ b/src/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageWriterSpi.java	Fri May 08 15:38:21 2009 +0400
@@ -28,6 +28,7 @@
 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 @@
               JPEG.suffixes,
               JPEG.MIMETypes,
               "com.sun.imageio.plugins.jpeg.JPEGImageWriter",
-              STANDARD_OUTPUT_TYPE,
+              new Class[] { ImageOutputStream.class },
               readerSpiNames,
               true,
               JPEG.nativeStreamMetadataFormatName,
--- a/src/share/classes/com/sun/imageio/plugins/png/PNGImageReaderSpi.java	Thu May 07 10:44:45 2009 +0200
+++ b/src/share/classes/com/sun/imageio/plugins/png/PNGImageReaderSpi.java	Fri May 08 15:38:21 2009 +0400
@@ -60,7 +60,7 @@
               suffixes,
               MIMETypes,
               readerClassName,
-              STANDARD_INPUT_TYPE,
+              new Class[] { ImageInputStream.class },
               writerSpiNames,
               false,
               null, null,
--- a/src/share/classes/com/sun/imageio/plugins/png/PNGImageWriterSpi.java	Thu May 07 10:44:45 2009 +0200
+++ b/src/share/classes/com/sun/imageio/plugins/png/PNGImageWriterSpi.java	Fri May 08 15:38:21 2009 +0400
@@ -34,6 +34,7 @@
 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 @@
                 suffixes,
                 MIMETypes,
                 writerClassName,
-                STANDARD_OUTPUT_TYPE,
+                new Class[] { ImageOutputStream.class },
                 readerSpiNames,
                 false,
                 null, null,
--- a/src/share/classes/com/sun/imageio/plugins/wbmp/WBMPImageReaderSpi.java	Thu May 07 10:44:45 2009 +0200
+++ b/src/share/classes/com/sun/imageio/plugins/wbmp/WBMPImageReaderSpi.java	Fri May 08 15:38:21 2009 +0400
@@ -51,7 +51,7 @@
               entensions,
               mimeType,
               "com.sun.imageio.plugins.wbmp.WBMPImageReader",
-              STANDARD_INPUT_TYPE,
+              new Class[] { ImageInputStream.class },
               writerSpiNames,
               true,
               null, null, null, null,
--- a/src/share/classes/com/sun/imageio/plugins/wbmp/WBMPImageWriterSpi.java	Thu May 07 10:44:45 2009 +0200
+++ b/src/share/classes/com/sun/imageio/plugins/wbmp/WBMPImageWriterSpi.java	Fri May 08 15:38:21 2009 +0400
@@ -28,6 +28,7 @@
 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 @@
               entensions,
               mimeType,
               "com.sun.imageio.plugins.wbmp.WBMPImageWriter",
-              STANDARD_OUTPUT_TYPE,
+              new Class[] { ImageOutputStream.class },
               readerSpiNames,
               true,
               null, null, null, null,
--- a/src/share/classes/javax/imageio/spi/ImageReaderSpi.java	Thu May 07 10:44:45 2009 +0200
+++ b/src/share/classes/javax/imageio/spi/ImageReaderSpi.java	Fri May 08 15:38:21 2009 +0400
@@ -77,7 +77,10 @@
      * 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 @@
             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();
--- a/src/share/classes/javax/imageio/spi/ImageWriterSpi.java	Thu May 07 10:44:45 2009 +0200
+++ b/src/share/classes/javax/imageio/spi/ImageWriterSpi.java	Fri May 08 15:38:21 2009 +0400
@@ -77,9 +77,12 @@
 
     /**
      * 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 @@
             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();