[jdom-interest] PartialList not conforming List interface (using JDK 1.1 collections)

Gabor Greif gabor at no.netopia.com
Fri Jul 7 06:45:30 PDT 2000

PartialList l;
l.add(l.size(), "new");

will throw IndexOutOfBoundsException

But the spec says that this should only be thrown if (index < 0 || index >

Stepping into the method

    public void add(int index, Object current) {
        backingList.add(backingList.indexOf(get(index)), current);	<<

shows that the exception comes from the marked line. backingList is a
LinkedList, and that is defined in the JDK 1.1 collections jar in package

So the bug seems to be in Suns code. Has anybody experienced this before.
I heard that the com.sun.java.util.collections.LinkedList package is
basically identical to the java.util.LinkedList JDK2 package. Then the bug
must be there too.

For now I have made this fix to PartialList:

    public void add(int index, Object current) {
        if (index == backingList.size())
        	backingList.add(backingList.indexOf(get(index)), current);


More information about the jdom-interest mailing list