United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-4467611 : spec: ImageTypeSpecifier - unspecified exceptions in createGrayscale

Details
Type:
Bug
Submit Date:
2001-06-08
Status:
Resolved
Updated Date:
2004-04-02
Project Name:
JDK
Resolved Date:
2003-08-11
Component:
client-libs
OS:
generic
Sub-Component:
javax.imageio
CPU:
generic
Priority:
P4
Resolution:
Fixed
Affected Versions:
1.4.0,5.0
Fixed Versions:
5.0 (tiger)

Related Reports
Relates:

Sub Tasks

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
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
                                     
2003-07-21
PUBLIC COMMENTS

spec: ImageTypeSpecifier - unspecified exceptions in createGrayscale
                                     
2004-06-10
CONVERTED DATA

BugTraq+ Release Management Values

COMMIT TO FIX:
tiger

FIXED IN:
tiger

INTEGRATED IN:
tiger
tiger-b15


                                     
2004-06-14



Hardware and Software, Engineered to Work Together