--- jsr166/src/main/java/util/Vector.java 2016/12/05 00:08:01 1.40
+++ jsr166/src/main/java/util/Vector.java 2018/03/28 02:50:41 1.48
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1994, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1994, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -70,7 +70,7 @@ import java.util.function.UnaryOperator;
*
*
As of the Java 2 platform v1.2, this class was retrofitted to
* implement the {@link List} interface, making it a member of the
- *
+ *
* Java Collections Framework. Unlike the new collection
* implementations, {@code Vector} is synchronized. If a thread-safe
* implementation is not needed, it is recommended to use {@link
@@ -307,8 +307,9 @@ public class Vector
if (newSize > elementData.length)
grow(newSize);
final Object[] es = elementData;
- for (int to = elementCount, i = elementCount = newSize; i < to; i++)
+ for (int to = elementCount, i = newSize; i < to; i++)
es[i] = null;
+ elementCount = newSize;
}
/**
@@ -985,6 +986,9 @@ public class Vector
return bulkRemove(e -> !c.contains(e));
}
+ /**
+ * @throws NullPointerException {@inheritDoc}
+ */
@Override
public boolean removeIf(Predicate super E> filter) {
Objects.requireNonNull(filter);
@@ -1023,7 +1027,6 @@ public class Vector
setBit(deathRow, i - beg);
if (modCount != expectedModCount)
throw new ConcurrentModificationException();
- expectedModCount++;
modCount++;
int w = beg;
for (i = beg; i < end; i++)
@@ -1353,6 +1356,9 @@ public class Vector
}
}
+ /**
+ * @throws NullPointerException {@inheritDoc}
+ */
@Override
public synchronized void forEach(Consumer super E> action) {
Objects.requireNonNull(action);
@@ -1366,6 +1372,9 @@ public class Vector
// checkInvariants();
}
+ /**
+ * @throws NullPointerException {@inheritDoc}
+ */
@Override
public synchronized void replaceAll(UnaryOperator operator) {
Objects.requireNonNull(operator);
@@ -1416,7 +1425,7 @@ public class Vector
private int fence; // -1 until used; then one past last index
private int expectedModCount; // initialized when fence set
- /** Create new spliterator covering the given range */
+ /** Creates new spliterator covering the given range. */
VectorSpliterator(Object[] array, int origin, int fence,
int expectedModCount) {
this.array = array;
@@ -1445,9 +1454,8 @@ public class Vector
@SuppressWarnings("unchecked")
public boolean tryAdvance(Consumer super E> action) {
+ Objects.requireNonNull(action);
int i;
- if (action == null)
- throw new NullPointerException();
if (getFence() > (i = index)) {
index = i + 1;
action.accept((E)array[i]);
@@ -1460,8 +1468,7 @@ public class Vector
@SuppressWarnings("unchecked")
public void forEachRemaining(Consumer super E> action) {
- if (action == null)
- throw new NullPointerException();
+ Objects.requireNonNull(action);
final int hi = getFence();
final Object[] a = array;
int i;