[jdom-interest] addAll(Collection c) throws out of bounds exception

Jochen Strunk strunk at signal7.de
Mon Mar 19 09:51:00 PST 2001


Hi,

the following sample code:

Element element = new Element("parent");
Element child1 = new Element("child1");
Element child2 = new Element("child2");

element.addContent("textnode1");
element.addContent(child1);
element.addContent("textnode2");
element.addContent(child2);
	
Element child3 = new Element("child3");
Element child4 = new Element("child4");
List newChildren = new ArrayList();
newChildren.add(child3);
newChildren.add(child4);

List children = element.getChildren();
children.addAll(newChildren);

throws an IndexOutOfBoundsException.

This only happens when having mixed content because then
backingList.indexOf(getLast()) in addAll(Collection c)
might exceed the size of partial list.

jochen strunk



(-) Jochen Strunk
(-) SIGNAL 7 Gesellschaft für Informationstechnologie mbH
(-) Brüder-Knauß-Str. 79 - 64285 Darmstadt,
(-) Tel: 06151 665402, Fax: 06151 665373
(-) strunk at signal7.de, www.signal7.de




More information about the jdom-interest mailing list