[jdom-interest] Bug in org.jdom.PartialList.addLast

Scott M Stark scott_stark at displayscape.com
Mon Nov 13 12:41:10 PST 2000

This little program demonstrate a problem with the org.jdom.PartialList.addLast() method.
It is calling getLast() which is guarenteed to fail when there are no items in the list. This is
seen in the b5 release.

bash-2.04$ cat tstAdd.java
import java.util.List;
import org.jdom.*;

class tstAdd
        public static void main(String[] args)
                Element e = new Element("ProjectFolder");
                List children = e.getChildren();
                children.add(0, new Element("ProjectFile"));
bash-2.04$ java -classpath ".;build/jdom.jar" tstAdd
Exception in thread "main" java.util.NoSuchElementException
        at java.util.LinkedList.getLast(LinkedList.java:107)
        at org.jdom.PartialList.addLast(PartialList.java:160)
        at org.jdom.PartialList.add(PartialList.java:333)
        at tstAdd.main(tstAdd.java:10)

More information about the jdom-interest mailing list