--- jsr166/src/main/java/util/Vector.java 2005/11/27 14:54:23 1.3
+++ jsr166/src/main/java/util/Vector.java 2006/02/07 20:54:24 1.8
@@ -1,12 +1,11 @@
/*
* %W% %E%
*
- * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
package java.util;
-import java.util.*; // for javadoc (till 6280605 is fixed)
/**
* The Vector
class implements a growable array of
@@ -147,13 +146,11 @@ public class Vector
* @since 1.2
*/
public Vector(Collection extends E> c) {
- Object[] a = c.toArray();
- elementCount = a.length;
- // If c.toArray incorrectly doesn't return Object[], copy it.
- if (a.getClass() == Object[].class)
- elementData = a;
- else
- elementData = Arrays.copyOf(a, a.length, Object[].class);
+ elementData = c.toArray();
+ elementCount = elementData.length;
+ // c.toArray might (incorrectly) not return Object[] (see 6260652)
+ if (elementData.getClass() != Object[].class)
+ elementData = Arrays.copyOf(elementData, elementCount, Object[].class);
}
/**
@@ -1088,11 +1085,11 @@ public class Vector
public boolean hasNext() {
// Racy but within spec, since modifications are checked
// within or after synchronization in next/previous
- return cursor < Vector.this.elementCount;
+ return cursor != elementCount;
}
public boolean hasPrevious() {
- return cursor > 0;
+ return cursor != 0;
}
public int nextIndex() {
@@ -1117,7 +1114,8 @@ public class Vector
throw new ConcurrentModificationException();
}
}
- public E previous() {
+
+ public E previous() {
try {
int i = cursor - 1;
E prev = get(i);
@@ -1143,7 +1141,7 @@ public class Vector
cursor--;
lastRet = -1;
expectedModCount = modCount;
- } catch (IndexOutOfBoundsException e) {
+ } catch (IndexOutOfBoundsException ex) {
throw new ConcurrentModificationException();
}
}