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.3 by dl, Sun Nov 27 14:54:23 2005 UTC vs.
Revision 1.8 by jsr166, Tue Feb 7 20:54:24 2006 UTC

# Line 1 | Line 1
1   /*
2   * %W% %E%
3   *
4 < * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
4 > * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
5   * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6   */
7  
8   package java.util;
9 import java.util.*; // for javadoc (till 6280605 is fixed)
9  
10   /**
11   * The <code>Vector</code> class implements a growable array of
# Line 147 | Line 146 | public class Vector<E>
146       * @since   1.2
147       */
148      public Vector(Collection<? extends E> c) {
149 <        Object[] a = c.toArray();
150 <        elementCount = a.length;
151 <        // If c.toArray incorrectly doesn't return Object[], copy it.
152 <        if (a.getClass() == Object[].class)
153 <            elementData = a;
155 <        else
156 <            elementData = Arrays.copyOf(a, a.length, Object[].class);
149 >        elementData = c.toArray();
150 >        elementCount = elementData.length;
151 >        // c.toArray might (incorrectly) not return Object[] (see 6260652)
152 >        if (elementData.getClass() != Object[].class)
153 >            elementData = Arrays.copyOf(elementData, elementCount, Object[].class);
154      }
155  
156      /**
# Line 1088 | Line 1085 | public class Vector<E>
1085          public boolean hasNext() {
1086              // Racy but within spec, since modifications are checked
1087              // within or after synchronization in next/previous
1088 <            return cursor < Vector.this.elementCount;
1088 >            return cursor != elementCount;
1089          }
1090  
1091          public boolean hasPrevious() {
1092 <            return cursor > 0;
1092 >            return cursor != 0;
1093          }
1094  
1095          public int nextIndex() {
# Line 1117 | Line 1114 | public class Vector<E>
1114                      throw new ConcurrentModificationException();
1115              }
1116          }
1117 <        public E previous() {
1117 >
1118 >        public E previous() {
1119              try {
1120                  int i = cursor - 1;
1121                  E prev = get(i);
# Line 1143 | Line 1141 | public class Vector<E>
1141                      cursor--;
1142                  lastRet = -1;
1143                  expectedModCount = modCount;
1144 <            } catch (IndexOutOfBoundsException e) {
1144 >            } catch (IndexOutOfBoundsException ex) {
1145                  throw new ConcurrentModificationException();
1146              }
1147          }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines