--- jsr166/src/main/java/util/Vector.java 2005/11/28 03:28:25 1.4 +++ 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 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() {