-
Bug
-
Resolution: Fixed
-
P3
-
1.4.0
-
beta2
-
generic
-
generic
Name: vrR10176 Date: 05/29/2001
The description (jdk1.4.0beta-b65) of the following methods of
the class javax.imageio.plugins.jpeg.JPEGImageWriteParam
was copied from the class javax.imageio.ImageWriteParam:
public void unsetCompression(),
public boolean isCompressionLossless(),
public String[] getCompressionQualityDescriptions(),
public float[] getCompressionQualityValues(),
But these descriptions contradict to the methods implementation in some cases.
Here is more detail description:
======================================
public void unsetCompression()
Api spec says:
"The default implementation sets the instance variable compressionType
to null, and the instance variable compressionQuality to 1.0F."
But the method implementation sets compressionQuality to JPEG.DEFAULT_QUALITY
(equals to 0.75F) and does nothing with compressionType.
Api spec says:
"Throws:
UnsupportedOperationException - if the plug-in does not support tiling"
But method implementation does not contains 'throw' statement for this
exception. Therefore if class JPEGImageWriteParam is extended without method
overriding, this method may work incorrectly.
Moreover the word 'tiling' in description is a typo copied from ImageWriteParam.
======================================
public boolean isCompressionLossless(),
The description of this method contains a lot of assertions, but
the method source contains only one statement 'return false;'.
This implementation does not conform to the method description and
works incorrectly, for example see bug report 4463683.
======================================
public String[] getCompressionQualityDescriptions(),
public float[] getCompressionQualityValues(),
Api spec says about both methods:
"Throws:
UnsupportedOperationException - if the writer does not support compression.
...
IllegalStateException - if the set of legal compression types is non-null and the
current compression type is null."
But the methods implementation does not contain 'throw' statement for these
exceptions, therefore these methods may work incorrectly.
For example, execute following test. It checks assertion
"Throws:
IllegalStateException - if the set of legal compression types is non-null
and the current compression type is null."
------------------------ test.java ------------------------
import javax.imageio.plugins.jpeg.JPEGImageWriteParam;
public class test {
public static void main(String[] argv) {
JPEGImageWriteParam imageWriteParam = new JPEGImageWriteParam(null);
imageWriteParam.setCompressionMode(JPEGImageWriteParam.MODE_EXPLICIT);
imageWriteParam.setCompressionType(null);
System.out.println("Set of legal compression types is: " +
imageWriteParam.getCompressionTypes() + " (non-null)");
System.out.println("The current compression type is: " +
imageWriteParam.getCompressionType());
try {
imageWriteParam.getCompressionQualityValues();
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
Set of legal compression types is: [Ljava.lang.String;@6f0472 (non-null)
The current compression type is: null
Test failed. IllegalStateException was expected
------------------------------------------------------------
======================================
The implementation and description of these methods should be conformed.
======================================================================
- relates to
-
JDK-4463683 isCompressionLossless() does not throw IllegalStateException
-
- Resolved
-