[jdom-interest] Iterator.remove() is calling a non-overloaded method to remove children from an element.

Peter V. Gadjokov pvg at c-c-s.com
Wed Sep 27 12:40:03 PDT 2000

>Shouldn't be that hard to fix, but it would take a while to get familiar
>with the JDOM code and CVS, so I think I'd better let someone who knows
>they're doing add support for Iterator.remove().

It might be a little harder to fix than it looks, most likely PartialList
will have to provide its own Iterator (or perhaps someone can write a
ListView-type class that does not replicate storage and is not so gory).
PartialList _does_ appear to override all the relevant methods and take care
of setting the parent to null. The trouble is that the ListIterator impl
inside LinkedList (the superclass of PartialList, the ListIterator impl is a
private class it defines) does not actually call LinkedList.remove(Object),
it calls 
which is a private method and does all the work. PartialList never gets a
chance to get a method in edgewise. This is a little tricky to see in a
debugger because the private method is inlined in the ListItr
implementation. It's also not completely obvious from a quick glance at the
source since the type declaration of the 'lastReturned' ivar is no longer
visible in one's editor window. Isn't overloading fun?

In any event, the fix is worth thinking about some. It is also an
interesting datapoint in the 'is Element a List' debate - neither the person
who wrote the class nor the people who use JDOM (myself included) ever made
use of the 'live list' functionality enough to notice the issue :)


More information about the jdom-interest mailing list