--- jsr166/src/main/java/util/ArrayList.java 2019/05/22 17:36:58 1.67 +++ jsr166/src/main/java/util/ArrayList.java 2020/01/10 21:32:08 1.70 @@ -109,6 +109,7 @@ import jdk.internal.util.ArraysSupport; public class ArrayList extends AbstractList implements List, RandomAccess, Cloneable, java.io.Serializable { + // OPENJDK @java.io.Serial private static final long serialVersionUID = 8683452581122892189L; /** @@ -538,7 +539,7 @@ public class ArrayList extends Abstra if (to > es.length) { throw new ConcurrentModificationException(); } - Iterator oit = other.iterator(); + var oit = other.iterator(); for (; from < to; from++) { if (!oit.hasNext() || !Objects.equals(es[from], oit.next())) { return false; @@ -855,6 +856,7 @@ public class ArrayList extends Abstra * instance is emitted (int), followed by all of its elements * (each an {@code Object}) in the proper order. */ + // OPENJDK @java.io.Serial private void writeObject(java.io.ObjectOutputStream s) throws java.io.IOException { // Write out element count, and any hidden stuff @@ -882,6 +884,7 @@ public class ArrayList extends Abstra * could not be found * @throws java.io.IOException if an I/O error occurs */ + // OPENJDK @java.io.Serial private void readObject(java.io.ObjectInputStream s) throws java.io.IOException, ClassNotFoundException { @@ -1136,7 +1139,7 @@ public class ArrayList extends Abstra this.parent = parent; this.offset = parent.offset + fromIndex; this.size = toIndex - fromIndex; - this.modCount = root.modCount; + this.modCount = parent.modCount; } public E set(int index, E element) { @@ -1289,7 +1292,7 @@ public class ArrayList extends Abstra return new ListIterator() { int cursor = index; int lastRet = -1; - int expectedModCount = root.modCount; + int expectedModCount = SubList.this.modCount; public boolean hasNext() { return cursor != SubList.this.size; @@ -1333,7 +1336,7 @@ public class ArrayList extends Abstra final Object[] es = root.elementData; if (offset + i >= es.length) throw new ConcurrentModificationException(); - for (; i < size && modCount == expectedModCount; i++) + for (; i < size && root.modCount == expectedModCount; i++) action.accept(elementAt(es, offset + i)); // update once at end to reduce heap write traffic cursor = i; @@ -1359,7 +1362,7 @@ public class ArrayList extends Abstra SubList.this.remove(lastRet); cursor = lastRet; lastRet = -1; - expectedModCount = root.modCount; + expectedModCount = SubList.this.modCount; } catch (IndexOutOfBoundsException ex) { throw new ConcurrentModificationException(); } @@ -1385,7 +1388,7 @@ public class ArrayList extends Abstra SubList.this.add(i, e); cursor = i + 1; lastRet = -1; - expectedModCount = root.modCount; + expectedModCount = SubList.this.modCount; } catch (IndexOutOfBoundsException ex) { throw new ConcurrentModificationException(); }