-
Bug
-
Resolution: Fixed
-
P3
-
1.4.0
-
beta
-
generic
-
generic
Name: dkR10031 Date: 03/25/2001
Specification of the method
javax.imageio.metadata.IIOMetadataFormatImpl.getObjectMinValue says:
"This method should only be called if getObjectValueType returns VALUE_RANGE."
The implementation (JDK 1.4.0beta, build b56) is fully conformant to this
spec, that is it throws IllegalArgumentException when at least one of the
min and max values is inclusive. However, this specification seems to be in error,
since there should be means to obtain boundary values for any type of range.
Besides, the description of the method contradicts to Throws section which says:
"IllegalArgumentException - if the Object is not defined as a range".
Note also that similar methods for element attributes defined as a range are
described and implemented in other way.
The same problem takes place for getObjectMaxValue method.
I think that both specification and implementation of the two methods should be
corrected.
This bug causes failures of new JCK tests:
api/javax_imageio/metadata/IIOMetadataFormatImpl#addObjectValueTests
api/javax_imageio/metadata/IIOMetadataFormatImpl#getObjectMinValueTests
api/javax_imageio/metadata/IIOMetadataFormatImpl#getObjectMaxValueTests
To reproduce the bug run the following test:
------------ test.java ------------------------
import javax.imageio.metadata.IIOMetadataFormatImpl;
import javax.imageio.ImageTypeSpecifier;
public class test {
public static void main(String argv[]) {
Integer defValue = new Integer(1);
Integer minValue = new Integer(0);
Integer maxValue = new Integer(10);
MyFormatImpl fmt = new MyFormatImpl("root", 1, 10);
fmt.addObjectValue("root", defValue.getClass(), defValue, minValue, maxValue, true,
false);
try {
Integer act_min = (Integer)fmt.getObjectMinValue("root");
if (! act_min.equals(minValue))
System.out.println("invalid min value: " + act_min);
} catch (Throwable e) {
System.out.println("getObjectMinValue: unexpected exception: " + e);
}
try {
Integer act_max = (Integer)fmt.getObjectMaxValue("root");
if (! act_max.equals(maxValue))
System.out.println("invalid max value: " + act_max);
} catch (Throwable e) {
System.out.println("getObjectMaxValue: unexpected exception: " + e);
}
}
}
class MyFormatImpl extends IIOMetadataFormatImpl {
MyFormatImpl(String root, int minChildren, int maxChildren) {
super(root, minChildren, maxChildren);
}
public void addObjectValue(String elementName, Class classType, Object defaultValue,
Comparable minValue, Comparable maxValue,
boolean minInclusive, boolean maxInclusive) {
super.addObjectValue(elementName, classType, defaultValue, minValue, maxValue,
minInclusive, maxInclusive);
}
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-b56)
Java HotSpot(TM) Client VM (build 1.4-beta-B56, mixed mode)
$ javac test.java
$ java test
getObjectMinValue: unexpected exception: java.lang.IllegalArgumentException: Not a range!
getObjectMaxValue: unexpected exception: java.lang.IllegalArgumentException: Not a range!
-----------------------------------------------
======================================================================