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 |
|
/** |