JDK-4467611 : spec: ImageTypeSpecifier - unspecified exceptions in createGrayscale
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.imageio
  • Affected Version: 1.4.0,5.0
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2001-06-08
  • Updated: 2017-05-16
  • Resolved: 2003-08-11
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
5.0 tigerFixed
Related Reports
Relates :  
Description

Name: bkR10012			Date: 06/08/2001


Spec. of the class javax.imageio.ImageTypeSpecifier
doesn't describe any exceptions for methods
createGrayscale(bits, dataType, isSigned)
createGrayscale(bits, dataType, isSigned, isAlphaPremultiplied)

But these methods throw unexpected exceptions in following cases:

- bits = 100;
IllegalArgumentException: Number of bits must be between 1 and 16. 

- bits = 10; dataType = DataBuffer.TYPE_BYTE; 
java.awt.image.RasterFormatException: MultiPixelPackedSampleModel does not
allow pixels to span data element boundaries

- dataType = 100;
IllegalArgumentException: Unknown data type 100

See test source and log below.
---------------------------------------- test.java
import javax.imageio.ImageTypeSpecifier;
import java.awt.image.DataBuffer;

public class test {

    public static void main(String argv[]) {
        test t = new test();
        t.createGrayscaleTest();
    }

    public void createGrayscaleTest() {
    int bits = 8;
    int dataType = DataBuffer.TYPE_BYTE; 
    boolean isSigned = true;
// testcase 1
        try {
            ImageTypeSpecifier.createGrayscale(100, dataType, isSigned);
        } catch (Throwable e) {
            System.out.println("testcase 1: " + e);     
        }
 // testcase 2
        try {
            ImageTypeSpecifier.createGrayscale(10, dataType, isSigned);
        } catch (Throwable e) {
            System.out.println("testcase 2: " + e);     
        }
// testcase 3
        try {
            ImageTypeSpecifier.createGrayscale(bits, 100, isSigned);
        } catch (Throwable e) {
            System.out.println("testcase 3: " + e);     
        }
   }
}
----------------------------------------
% java -version
java version "1.4.0-beta_refresh"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta_refresh-b66)
Java HotSpot(TM) Client VM (build 1.4.0-beta_refresh-b66, mixed mode)
% java test
testcase 1: java.lang.IllegalArgumentException: Number of bits must be between 1 
and 16.
testcase 2: java.awt.image.RasterFormatException: MultiPixelPackedSampleModel 
does not allow pixels to span data element boundaries
testcase 3: java.lang.IllegalArgumentException: Unknown data type 100
----------------------------------------

This bug causes failure of the new JCK test
api/javax_imageio/ImageTypeSpecifier/index.html#createGrayscale

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

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: tiger FIXED IN: tiger INTEGRATED IN: tiger tiger-b15
14-06-2004

PUBLIC COMMENTS spec: ImageTypeSpecifier - unspecified exceptions in createGrayscale
10-06-2004

EVALUATION Documented missing exceptions in the javadoc for both createGrayscale() methods. Also now checking (and throwing the appropriate exceptions) for bad input parameters in those methods. ###@###.### 2003-07-21
21-07-2003