bug-classpath
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug classpath/24752] ArrayList#listIterator(int).nextIndex() and previo


From: mark at klomp dot org
Subject: [Bug classpath/24752] ArrayList#listIterator(int).nextIndex() and previousIndex() should not call checkMod().
Date: 11 Nov 2005 10:30:34 -0000


------- Comment #3 from mark at gcc dot gnu dot org  2005-11-11 10:30 -------
Subject: Re:  ArrayList#listIterator(int).nextIndex()
        and previousIndex() should not call checkMod().

On Fri, 2005-11-11 at 01:00 +0000, ujihara at aurora dot dti dot ne dot
jp wrote:
> 
> ------- Comment #2 from ujihara at aurora dot dti dot ne dot jp  2005-11-11 
> 01:00 -------
>         ArrayList list = new ArrayList();
>         list.add(new Object());
>         list.add(new Object());
>         list.add(new Object());
>         ListIterator it = list.listIterator(1);
>         it.next();
>         list.remove(1);
>         it.nextIndex();

You are removing an element from the backing store of the iterator. The
iterator that you get from ArrayList is fail-fast. Which means that it
tries to detect any changes occurring to the backing store and throws an
exception if that happens and it is detected. JCL2ev1sup says that
nextIndex can throw a ConcurrentModificationException if the list was
modified by something else than this list iterator and that is precisely
what happens here.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24752





reply via email to

[Prev in Thread] Current Thread [Next in Thread]