Reponse to bug report (spurious ConcurrentModificationException in ArrayList)

Cyrille Artho c.artho at
Tue Aug 11 04:13:29 UTC 2015

Dear all,
I'd like to write a response to my bug report at
but I didn't get an OpenJDK login when I submitted the report.

In this particular case, it should be noted that my test was minimal. If 
one has at least one element in the list before the iterator is created, 
then throws no exception when used on any collection except 

This means that ArrayList and its legacy brethren are the only classes 
that generate a spurious exception, and only after list.remove(-1) was 
called before using the iterator. The spurious exception prevents future 
access to data where other containers work as expected.

Currently it is being considered to keep the current (faulty) behavior, 
but based on the new test case, I strongly advise correcting this bug.

With the new test case, the information about the bug becomes:

EXPECTED - returns 42

This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.ConcurrentModificationException;
import java.util.Iterator;
import java.util.NoSuchElementException;

public class iterator_test {
    public static void main(String[] argv) {
      /* BUG: Sequence of arrayList.iterator,
         arrayList.add(new Integer(1)),
         produces ConcurrentModificationException. */
      ArrayList<Integer> testArrayList = new ArrayList<Integer>();
      testArrayList.add(new Integer(42));
      Iterator<Integer> it = testArrayList.iterator();
      try {
      } catch (IndexOutOfBoundsException e) {
      try {
        Integer result =;
        assert(result == 42);
      } catch (ConcurrentModificationException e) {
        System.err.println("Should be 42!");

---------- END SOURCE ----------
Cyrille Artho -
Those who will not reason, are bigots, those who cannot,
are fools, and those who dare not, are slaves.
		-- George Gordon Noel Byron

More information about the core-libs-dev mailing list