--- a/jdk/src/share/classes/java/util/IdentityHashMap.java Tue Apr 17 11:59:12 2012 -0700
+++ b/jdk/src/share/classes/java/util/IdentityHashMap.java Tue Apr 17 12:21:56 2012 -0700
@@ -327,6 +327,7 @@
*
* @see #put(Object, Object)
*/
+ @SuppressWarnings("unchecked")
public V get(Object key) {
Object k = maskNull(key);
Object[] tab = table;
@@ -431,7 +432,8 @@
Object item;
while ( (item = tab[i]) != null) {
if (item == k) {
- V oldValue = (V) tab[i + 1];
+ @SuppressWarnings("unchecked")
+ V oldValue = (V) tab[i + 1];
tab[i + 1] = value;
return oldValue;
}
@@ -524,7 +526,8 @@
if (item == k) {
modCount++;
size--;
- V oldValue = (V) tab[i + 1];
+ @SuppressWarnings("unchecked")
+ V oldValue = (V) tab[i + 1];
tab[i + 1] = null;
tab[i] = null;
closeDeletion(i);
@@ -638,7 +641,7 @@
if (o == this) {
return true;
} else if (o instanceof IdentityHashMap) {
- IdentityHashMap m = (IdentityHashMap) o;
+ IdentityHashMap<?,?> m = (IdentityHashMap<?,?>) o;
if (m.size() != size)
return false;
@@ -650,7 +653,7 @@
}
return true;
} else if (o instanceof Map) {
- Map m = (Map)o;
+ Map<?,?> m = (Map<?,?>)o;
return entrySet().equals(m.entrySet());
} else {
return false; // o is not a Map
@@ -698,7 +701,7 @@
*/
public Object clone() {
try {
- IdentityHashMap<K,V> m = (IdentityHashMap<K,V>) super.clone();
+ IdentityHashMap<?,?> m = (IdentityHashMap<?,?>) super.clone();
m.entrySet = null;
m.table = table.clone();
return m;
@@ -768,7 +771,7 @@
int len = tab.length;
int d = deletedSlot;
- K key = (K) tab[d];
+ Object key = tab[d];
tab[d] = null; // vacate the slot
tab[d + 1] = null;
@@ -818,12 +821,14 @@
}
private class KeyIterator extends IdentityHashMapIterator<K> {
+ @SuppressWarnings("unchecked")
public K next() {
return (K) unmaskNull(traversalTable[nextIndex()]);
}
}
private class ValueIterator extends IdentityHashMapIterator<V> {
+ @SuppressWarnings("unchecked")
public V next() {
return (V) traversalTable[nextIndex() + 1];
}
@@ -854,16 +859,19 @@
this.index = index;
}
+ @SuppressWarnings("unchecked")
public K getKey() {
checkIndexForEntryUse();
return (K) unmaskNull(traversalTable[index]);
}
+ @SuppressWarnings("unchecked")
public V getValue() {
checkIndexForEntryUse();
return (V) traversalTable[index+1];
}
+ @SuppressWarnings("unchecked")
public V setValue(V value) {
checkIndexForEntryUse();
V oldValue = (V) traversalTable[index+1];
@@ -880,7 +888,7 @@
if (!(o instanceof Map.Entry))
return false;
- Map.Entry e = (Map.Entry)o;
+ Map.Entry<?,?> e = (Map.Entry<?,?>)o;
return (e.getKey() == unmaskNull(traversalTable[index]) &&
e.getValue() == traversalTable[index+1]);
}
@@ -1109,13 +1117,13 @@
public boolean contains(Object o) {
if (!(o instanceof Map.Entry))
return false;
- Map.Entry entry = (Map.Entry)o;
+ Map.Entry<?,?> entry = (Map.Entry<?,?>)o;
return containsMapping(entry.getKey(), entry.getValue());
}
public boolean remove(Object o) {
if (!(o instanceof Map.Entry))
return false;
- Map.Entry entry = (Map.Entry)o;
+ Map.Entry<?,?> entry = (Map.Entry<?,?>)o;
return removeMapping(entry.getKey(), entry.getValue());
}
public int size() {
@@ -1213,8 +1221,10 @@
// Read the keys and values, and put the mappings in the table
for (int i=0; i<size; i++) {
- K key = (K) s.readObject();
- V value = (V) s.readObject();
+ @SuppressWarnings("unchecked")
+ K key = (K) s.readObject();
+ @SuppressWarnings("unchecked")
+ V value = (V) s.readObject();
putForCreate(key, value);
}
}
@@ -1226,7 +1236,7 @@
private void putForCreate(K key, V value)
throws IOException
{
- K k = (K)maskNull(key);
+ Object k = maskNull(key);
Object[] tab = table;
int len = tab.length;
int i = hash(k, len);