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

isCompressionLossless() does not throw IllegalStateException

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      beta2
    • CPU:
      generic
    • OS:
      generic

      Description



      Name: vrR10176 Date: 05/29/2001



      Api spec (jdk1.4.0beta-b65) says about method
      javax.imageio.plugins.jpeg.JPEGImageWriteParam.isCompressionLossless():
      "public boolean isCompressionLossless()
           Description copied from class: ImageWriteParam
           Returns true if the current compression type provides lossless compression. If a plug-in
           provides only one mandatory compression type, then this method may be called without
           calling setCompressionType first.
      ...
           Throws:
      ...
               IllegalStateException - if the compression mode is not MODE_EXPLICIT.
      ..."

      But the method does not throw IllegalStateException when the compression mode is not MODE_EXPLICIT.
      The default JPEGImageWriteParam compression mode is MODE_COPY_FROM_METADATA.

      This bug causes failure of new JCK test:
      api/javax_imageio/plugins/jpeg/JPEGImageWriteParam/index.html#isCompressionLossless

      To reproduce the issue execute following test.
      ------------------------ test.java ------------------------
      import javax.imageio.plugins.jpeg.JPEGImageWriteParam;

      public class test {

          public static void main(String[] argv) {

              JPEGImageWriteParam imagewriteparam = new JPEGImageWriteParam(null);

              try {
                  System.out.println("compression mode is not MODE_EXPLICIT");
                  System.out.println("getCompressionMode() returns " + imagewriteparam.getCompressionMode() +
                                     ", not " + JPEGImageWriteParam.MODE_EXPLICIT);
                  imagewriteparam.isCompressionLossless();
                  System.out.println("Test failed. IllegalStateException was expected");
              } catch (IllegalStateException e) {
                  System.out.println("Test passed");
              }
          }
      }
      ------------ Logs ------------------------------------------
      $ java -version
      java version "1.4.0-beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta-b65)
      Java HotSpot(TM) Client VM (build 1.4.0-beta-b65, mixed mode)

      $ javac test.java

      $ java test
      compression mode is not MODE_EXPLICIT
      getCompressionMode() returns 3, not 2
      Test failed. IllegalStateException was expected

      -----------------------------------------------

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

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: