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.6 by jsr166, Tue Nov 29 06:19:39 2005 UTC

# Line 147 | Line 147 | public class Vector<E>
147       * @since   1.2
148       */
149      public Vector(Collection<? extends E> c) {
150 <        Object[] a = c.toArray();
151 <        elementCount = a.length;
152 <        // If c.toArray incorrectly doesn't return Object[], copy it.
153 <        if (a.getClass() == Object[].class)
154 <            elementData = a;
155 <        else
156 <            elementData = Arrays.copyOf(a, a.length, Object[].class);
150 >        elementData = c.toArray();
151 >        elementCount = elementData.length;
152 >        // c.toArray might (incorrectly) not return Object[] (see 6260652)
153 >        if (elementData.getClass() != Object[].class)
154 >            elementData = Arrays.copyOf(elementData, elementCount, Object[].class);
155      }
156  
157      /**
# Line 1088 | Line 1086 | public class Vector<E>
1086          public boolean hasNext() {
1087              // Racy but within spec, since modifications are checked
1088              // within or after synchronization in next/previous
1089 <            return cursor < Vector.this.elementCount;
1089 >            return cursor != elementCount;
1090          }
1091  
1092          public boolean hasPrevious() {
1093 <            return cursor > 0;
1093 >            return cursor != 0;
1094          }
1095  
1096          public int nextIndex() {
# Line 1117 | Line 1115 | public class Vector<E>
1115                      throw new ConcurrentModificationException();
1116              }
1117          }
1118 <        public E previous() {
1118 >
1119 >        public E previous() {
1120              try {
1121                  int i = cursor - 1;
1122                  E prev = get(i);
# Line 1143 | Line 1142 | public class Vector<E>
1142                      cursor--;
1143                  lastRet = -1;
1144                  expectedModCount = modCount;
1145 <            } catch (IndexOutOfBoundsException e) {
1145 >            } catch (IndexOutOfBoundsException ex) {
1146                  throw new ConcurrentModificationException();
1147              }
1148          }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines