Fix ConcurrentModificationException in ArrayList iterators.

OpenJdk's hasNext() implementation always checks the current size
of the list so it's possible for this function to return "false"
and then "true" if an element is subsequently added. Attempting to
iterate over that element will throw a ConcurrentModificationException.

The unit-test demonstrates the sequence of operations applications
were performing, usually from a (for : each) loop of listeners where the
last listener would add stuff to the list.

bug: 25867131
bug: 25867396
bug: 25866843
bug: 25866828

Change-Id: I785a3a44aba22e6872b9471551011f0dd28458de
2 files changed