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.57 by jsr166, Thu Oct 10 16:53:08 2019 UTC vs.
Revision 1.58 by jsr166, Fri Jul 24 20:57:26 2020 UTC

# Line 179 | Line 179 | public class Vector<E>
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      /**

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines