我看过了,好像里面的对于(key,value)是直接用e.value = value;赋值的,对于引用来说,应该就没有产生新的对象,而只是用新的指针也指向了它,所以感觉对于纯值clone()来说,是深层复制,但是对于存储引用的来说就不是深层的啦,不知道我的想法对不对。 private void putForCreate(Object key, Object value) { Object k = maskNull(key); int hash = hash(k); int i = indexFor(hash, table.length); /** * Look for preexisting entry for key. This will never happen for * clone or deserialize. It will only happen for construction if the * input Map is a sorted map whose ordering is inconsistent w/ equals. */ for (Entry e = table[i]; e != null; e = e.next) { if (e.hash == hash && eq(k, e.key)) { e.value = value; return; } } createEntry(hash, k, value, i); }
private void putForCreate(Object key, Object value) {
Object k = maskNull(key);
int hash = hash(k);
int i = indexFor(hash, table.length); /**
* Look for preexisting entry for key. This will never happen for
* clone or deserialize. It will only happen for construction if the
* input Map is a sorted map whose ordering is inconsistent w/ equals.
*/
for (Entry e = table[i]; e != null; e = e.next) {
if (e.hash == hash && eq(k, e.key)) {
e.value = value;
return;
}
} createEntry(hash, k, value, i);
}