179 |
|
* @since 1.2 |
180 |
|
*/ |
181 |
|
public Vector(Collection<? extends E> c) { |
182 |
< |
elementData = c.toArray(); |
183 |
< |
elementCount = elementData.length; |
184 |
< |
// defend against c.toArray (incorrectly) not returning Object[] |
185 |
< |
// (see e.g. https://bugs.openjdk.java.net/browse/JDK-6260652) |
186 |
< |
if (elementData.getClass() != Object[].class) |
187 |
< |
elementData = Arrays.copyOf(elementData, elementCount, Object[].class); |
182 |
> |
Object[] a = c.toArray(); |
183 |
> |
elementCount = a.length; |
184 |
> |
if (c.getClass() == ArrayList.class) { |
185 |
> |
elementData = a; |
186 |
> |
} else { |
187 |
> |
elementData = Arrays.copyOf(a, elementCount, Object[].class); |
188 |
> |
} |
189 |
|
} |
190 |
|
|
191 |
|
/** |