-
Bug
-
Resolution: Fixed
-
P3
-
1.4.0
-
beta2
-
generic
-
generic
Name: dkR10031 Date: 04/10/2001
Specification of the method
javax.imageio.metadata.IIOMetadataFormatImpl.getAttributeEnumerations says:
"Throws: ...
IllegalArgumentException - if the given attribute is not defined as an
enumeration."
However, the implementation (JDK 1.4.0beta, build b59) of the method
throws IllegalStateException instead of IllegalArgumentException when given
name of an attribute not defined as an enumeration.
This bug causes failure of new JCK test:
api/javax_imageio/metadata/IIOMetadataFormatImpl/index.html#getAttributeEnumerations
To reproduce the bug run the following test:
------------ test05.java ------------------------
import javax.imageio.metadata.IIOMetadataFormatImpl;
import javax.imageio.ImageTypeSpecifier;
class test05 {
public static void main(String argv[]) {
String[] result;
MyFormatImpl fmt = new MyFormatImpl("root", 1, 10);
fmt.addAttribute("root", "attr", fmt.DATATYPE_INTEGER, true, 2, 5);
try {
result = fmt.getAttributeEnumerations("root", "attr");
System.out.println("failed: no Exception");
} catch(IllegalArgumentException e) {
System.out.println("passed");
}
}
}
class MyFormatImpl extends IIOMetadataFormatImpl {
MyFormatImpl(String root, int minChildren, int maxChildren) {
super(root, minChildren, maxChildren);
}
public void addAttribute(String elementName, String attrName, int dataType,
boolean required, int listMinLength, int listMaxLength) {
super.addAttribute(elementName, attrName, dataType, required, listMinLength,
listMaxLength);
}
public boolean canNodeAppear(String elementName, ImageTypeSpecifier imageType) {
return true;
}
}
------------ 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 test05.java
$ java test05
Exception in thread "main" java.lang.IllegalStateException: Attribute not an
enumeration!
at
javax.imageio.metadata.IIOMetadataFormatImpl.getAttributeEnumerations(IIOMetadataForma
tImpl.java:1054)
at test05.main(test05.java:13)
======================================================================
Name: dkR10031 Date: 04/11/2001
The same problem occurs also for 4 more methods of IIOMetadataFormatImpl
class:
getAttributeListMaxLengthTests
getAttributeListMinLengthTests
getAttributeMaxValueTests
getAttributeMinValueTests
All they throw IllegalStateException instead of IllegalArgumentException
when given name of an attribute not suitable for the request.
======================================================================