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.55 by jsr166, Wed May 22 17:36:58 2019 UTC vs.
Revision 1.58 by jsr166, Fri Jul 24 20:57:26 2020 UTC

# Line 102 | Line 102 | public class Vector<E>
102       *
103       * @serial
104       */
105 +    @SuppressWarnings("serial") // Conditionally serializable
106      protected Object[] elementData;
107  
108      /**
# Line 124 | Line 125 | public class Vector<E>
125      protected int capacityIncrement;
126  
127      /** use serialVersionUID from JDK 1.0.2 for interoperability */
128 +    // OPENJDK @java.io.Serial
129      private static final long serialVersionUID = -2767605614048989439L;
130  
131      /**
# Line 177 | 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      /**
# Line 1157 | Line 1160 | public class Vector<E>
1160       * @throws ClassNotFoundException if the stream contains data
1161       *         of a non-existing class
1162       */
1163 +    // OPENJDK @java.io.Serial
1164      private void readObject(ObjectInputStream in)
1165              throws IOException, ClassNotFoundException {
1166          ObjectInputStream.GetField gfields = in.readFields();
# Line 1178 | Line 1182 | public class Vector<E>
1182       * @param s the stream
1183       * @throws java.io.IOException if an I/O error occurs
1184       */
1185 +    // OPENJDK @java.io.Serial
1186      private void writeObject(java.io.ObjectOutputStream s)
1187              throws java.io.IOException {
1188          final java.io.ObjectOutputStream.PutField fields = s.putFields();

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines