--- jsr166/src/main/java/util/Vector.java 2016/12/08 05:01:42 1.41
+++ jsr166/src/main/java/util/Vector.java 2017/05/06 06:49:46 1.46
@@ -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;
}
/**
@@ -1425,7 +1426,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;
@@ -1454,9 +1455,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]);
@@ -1469,8 +1469,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;