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

Comparing jsr166/src/main/java/util/concurrent/CopyOnWriteArrayList.java (file contents):
Revision 1.60 by jsr166, Sat Oct 1 22:09:39 2005 UTC vs.
Revision 1.61 by dl, Sun Nov 20 15:38:08 2005 UTC

# Line 97 | Line 97 | public class CopyOnWriteArrayList<E>
97       * @throws NullPointerException if the specified collection is null
98       */
99      public CopyOnWriteArrayList(Collection<? extends E> c) {
100 <        Object[] elements = new Object[c.size()];
101 <        int size = 0;
102 <        for (E e : c)
103 <            elements[size++] = e;
104 <        setArray(elements);
100 >        Object[] a = c.toArray();
101 >        // If c.toArray incorrectly doesn't return Object[], copy it.
102 >        if (a.getClass() != Object[].class)
103 >            a = Arrays.copyOf(a, a.length, Object[].class);
104 >        setArray(a);
105      }
106  
107      /**

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines