ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/main/java/util/Vector.java
(Generate patch)

Comparing jsr166/src/main/java/util/Vector.java (file contents):
Revision 1.5 by dl, Mon Nov 28 23:53:32 2005 UTC vs.
Revision 1.9 by jsr166, Sun Mar 19 17:59:39 2006 UTC

# Line 1 | Line 1
1   /*
2   * %W% %E%
3   *
4 < * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
4 > * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
5   * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6   */
7  
8   package java.util;
9 import java.util.*; // for javadoc (till 6280605 is fixed)
9  
10   /**
11   * The <code>Vector</code> class implements a growable array of
12   * objects. Like an array, it contains components that can be
13   * accessed using an integer index. However, the size of a
14   * <code>Vector</code> can grow or shrink as needed to accommodate
15 < * adding and removing items after the <code>Vector</code> has been created.<p>
15 > * adding and removing items after the <code>Vector</code> has been created.
16   *
17 < * Each vector tries to optimize storage management by maintaining a
17 > * <p>Each vector tries to optimize storage management by maintaining a
18   * <code>capacity</code> and a <code>capacityIncrement</code>. The
19   * <code>capacity</code> is always at least as large as the vector
20   * size; it is usually larger because as components are added to the
21   * vector, the vector's storage increases in chunks the size of
22   * <code>capacityIncrement</code>. An application can increase the
23   * capacity of a vector before inserting a large number of
24 < * components; this reduces the amount of incremental reallocation. <p>
24 > * components; this reduces the amount of incremental reallocation.
25   *
26 < * As of the Java 2 platform v1.2, this class has been retrofitted to
28 < * implement List, so that it becomes a part of Java's collection framework.
29 < * Unlike the new collection implementations, Vector is synchronized.<p>
30 < *
31 < * The Iterators returned by Vector's iterator and listIterator
26 > * <p>The Iterators returned by Vector's iterator and listIterator
27   * methods are <em>fail-fast</em>: if the Vector is structurally modified
28   * at any time after the Iterator is created, in any way except through the
29   * Iterator's own remove or add methods, the Iterator will throw a
# Line 44 | Line 39 | import java.util.*; // for javadoc (till
39   * throw <tt>ConcurrentModificationException</tt> on a best-effort basis.
40   * Therefore, it would be wrong to write a program that depended on this
41   * exception for its correctness:  <i>the fail-fast behavior of iterators
42 < * should be used only to detect bugs.</i><p>
42 > * should be used only to detect bugs.</i>
43   *
44 < * This class is a member of the
45 < * <a href="{@docRoot}/../guide/collections/index.html">
46 < * Java Collections Framework</a>.
44 > * <p>As of the Java 2 platform v1.2, this class was retrofitted to
45 > * implement the {@link List} interface, making it a member of the
46 > * <a href="{@docRoot}/../guide/collections/index.html"> Java
47 > * Collections Framework</a>.  Unlike the new collection
48 > * implementations, {@code Vector} is synchronized.
49   *
50   * @author  Lee Boynton
51   * @author  Jonathan Payne
# Line 147 | Line 144 | public class Vector<E>
144       * @since   1.2
145       */
146      public Vector(Collection<? extends E> c) {
147 <        Object[] a = c.toArray();
148 <        elementCount = a.length;
149 <        // If c.toArray incorrectly doesn't return Object[], copy it.
150 <        if (a.getClass() == Object[].class)
151 <            elementData = a;
155 <        else
156 <            elementData = Arrays.copyOf(a, a.length, Object[].class);
147 >        elementData = c.toArray();
148 >        elementCount = elementData.length;
149 >        // c.toArray might (incorrectly) not return Object[] (see 6260652)
150 >        if (elementData.getClass() != Object[].class)
151 >            elementData = Arrays.copyOf(elementData, elementCount, Object[].class);
152      }
153  
154      /**

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines