Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4441315

javax.imageio.ImageWriteParam.setProgressiveMode() throws wrong exception

XMLWordPrintable

    • beta2
    • generic
    • generic



      Name: vrR10176 Date: 04/12/2001



      Api spec (jdk1.4.0beta-b59) says about method
      javax.imageio.ImageWriteParam.setProgressiveMode():
      "public void setProgressiveMode(int mode)
        Specifies that the writer is to write the image out in a progressive mode
      such that the stream will contain a series of scans of increasing quality.
      The mode argument determines how the progression parameters are chosen, and
      must be either MODE_DISABLED, MODE_COPY_FROM_METADATA, or MODE_DEFAULT.
      Otherwise an IllegalArgumentException is thrown.
      The modes are interpreted as follows:
        MODE_DISABLED - No progression. Use this to turn off progession.
        MODE_COPY_FROM_METADATA - The output image will use whatever progression
          parameters are found in the metadata objects passed into the writer.
        MODE_DEFAULT - The image will be written progressively, with parameters chosen by the writer.
      The default is MODE_COPY_FROM_METADATA.
        Parameters: mode - The mode for setting progression in the output stream.
        Throws:
          UnsupportedOperationException - if the writer does not support progressive encoding.
          IllegalArgumentException - if mode is not one of the modes listed above."

      Therefore if passed mode argument is ImageWriteParam.MODE_EXPLICIT (this mode
      is not one of the modes listed above) then setProgressiveMode() should throw
      IllegalArgumentException, but the method throws UnsupportedOperationException.

      To reproduce the issue execute following test.
      ------------ myImageWriteParam.java ------------------------
      import javax.imageio.ImageWriteParam;

      public class myImageWriteParam extends ImageWriteParam {

      public myImageWriteParam() {
      super(null);
      super.canWriteProgressive = true;
      }

      public static void main(String[] argv) {
      myImageWriteParam myimagewriteparam = new myImageWriteParam();
      try{
      myimagewriteparam.setProgressiveMode(ImageWriteParam.MODE_EXPLICIT);
      System.out.println("Test failed. IllegalArgumentException was expected");
      } catch (IllegalArgumentException e) {
      System.out.println("Test passed");
      } catch (Throwable e) {
      System.out.println("Test failed with unexpected exception: " + e);
      }
      }
      }
      ------------ Logs ------------------------------------------
      $ java -version
      java version "1.4.0-beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta-b59)
      Java HotSpot(TM) Client VM (build 1.4.0-beta-b59, mixed mode)

      $ javac myImageWriteParam.java

      $ java myImageWriteParam
      Test failed with unexpected exception: java.lang.UnsupportedOperationException: MODE_EXPLICIT not supported for progressive output
      -----------------------------------------------

      ======================================================================

            dricesunw Daniel Rice (Inactive)
            rslasunw Rsla Rsla (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: