src/share/classes/java/util/IdentityHashMap.java
Print this page
rev 6617 : 8008785: IdentityHashMap.values().toArray(V[]) broken by JDK-8008167
Reviewed-by: alanb
*** 1104,1119 ****
if (a.length < size)
a = (T[]) Array.newInstance(a.getClass().getComponentType(), size);
Object[] tab = table;
int ti = 0;
for (int si = 0; si < tab.length; si += 2) {
! if (tab[si++] != null) { // key present ?
// more elements than expected -> concurrent modification from other thread
if (ti >= size) {
throw new ConcurrentModificationException();
}
! a[ti++] = (T) tab[si]; // copy value
}
}
// fewer elements than expected or concurrent modification from other thread detected
if (ti < size || expectedModCount != modCount) {
throw new ConcurrentModificationException();
--- 1104,1119 ----
if (a.length < size)
a = (T[]) Array.newInstance(a.getClass().getComponentType(), size);
Object[] tab = table;
int ti = 0;
for (int si = 0; si < tab.length; si += 2) {
! if (tab[si] != null) { // key present ?
// more elements than expected -> concurrent modification from other thread
if (ti >= size) {
throw new ConcurrentModificationException();
}
! a[ti++] = (T) tab[si+1]; // copy value
}
}
// fewer elements than expected or concurrent modification from other thread detected
if (ti < size || expectedModCount != modCount) {
throw new ConcurrentModificationException();