[kaffe] Re: LinkedList.subList severely broken
Daniel Bonniot
Daniel.Bonniot@inria.fr
Wed May 21 06:28:01 2003
This is a multi-part message in MIME format.
--------------050500070806060006060106
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
I think I spotted the bug in the implementation of
java.util.LinkedListIterator. It keeps a reference to the current list
node, but in the construction, that reference is incorrect when index is
not 0.
I attach a simple fix.
Cheers,
Daniel
--------------050500070806060006060106
Content-Type: text/plain;
name="LinkedListIterator.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="LinkedListIterator.diff"
Index: libraries/javalib/java/util/LinkedListIterator.java
===================================================================
RCS file: /cvs/kaffe/kaffe/libraries/javalib/java/util/LinkedListIterator.java,v
retrieving revision 1.1
diff -u -r1.1 LinkedListIterator.java
--- libraries/javalib/java/util/LinkedListIterator.java 14 Jul 1999 00:53:24 -0000 1.1
+++ libraries/javalib/java/util/LinkedListIterator.java 21 May 2003 13:22:52 -0000
@@ -26,6 +26,11 @@
LinkedListIterator(LinkedList list, int index) {
super(list, index);
elem = list.head;
+ // Position elem to the index'th element.
+ // We know that index is a valid index, because that was
+ // checked in the constructor in AbstractListIterator.
+ for (; index > 0; index--)
+ elem = elem.next;
}
public Object next() {
--------------050500070806060006060106--