-
Bug
-
Resolution: Fixed
-
P3
-
1.4.0
-
beta2
-
generic
-
generic
Name: dkR10031 Date: 04/02/2001
Specification of the method
javax.imageio.metadata.IIOMetadataFormatImpl.removeElement says:
"Removes an element from the format."
However, the implementation (JDK 1.4.0beta, build b58) of the method does
not act as described. After one of 2 root's childs is removed method
getChildNames still returns array of length 2 the first component of which
is the name of removed element.
Note that getChildPolicy invocation for the removed element correctly
results in IllegalArgumentException thrown.
This bug causes failure of new JCK test:
api/javax_imageio/metadata/IIOMetadataFormatImpl#removeElement
To reproduce the bug run the following test:
------------ test03.java ------------------------
import javax.imageio.metadata.IIOMetadataFormatImpl;
import javax.imageio.metadata.IIOMetadataFormat;
import javax.imageio.ImageTypeSpecifier;
public class test03 {
public static void main(String argv[]) {
String elem = "elem2";
int policy = IIOMetadataFormat.CHILD_POLICY_SOME;
MyFormatImpl fmt = new MyFormatImpl("root", 1, 10);
fmt.addElement("elem1", "root", policy);
fmt.addElement(elem, "root", policy);
fmt.removeElement("elem1");
try {
fmt.getChildPolicy("elem1");
} catch (IllegalArgumentException e) {
System.out.println(e.getMessage());
}
String[] chNames = fmt.getChildNames("root");
if (chNames.length != 1)
System.out.println("number of root's childs is not 1: " +
chNames.length);
if (! elem.equals(chNames[0]))
System.out.println("invalid name of remained element: " + chNames[0]);
if (chNames.length == 1 && elem.equals(chNames[0]))
System.out.println("Passed");
}
}
class MyFormatImpl extends IIOMetadataFormatImpl {
MyFormatImpl(String root, int minChildren, int maxChildren) {
super(root, minChildren, maxChildren);
}
public void addElement(String elementName, String parentName, int childPolicy) {
super.addElement(elementName, parentName, childPolicy);
}
public void removeElement(String elementName) {
super.removeElement(elementName);
}
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-b58)
Java HotSpot(TM) Client VM (build 1.4.0-beta-b58, mixed mode)
$ javac test03.java
$ java test03
No such element "elem1"!
number of root's childs is not 1: 2
invalid name of remained element: elem1
======================================================================