Follow

today i learned java stack overflows if you try to insert a map into itself as a key, but not as a value

oh my god is it because Map.hashCode calls hashCode on every key

@aescling assuming HashMap, that shouldn't be the difference: its hash code includes both keys and values. Also put calculates the hash of the key well before making any changes to the HashMap.

Tho it seems like whenever a resize triggers it will stack overflow for both the key and value cases for that reason.

also it would be impossible to reliably actually get a HashMap out of itself (since the hash it'll be stored under won't be true once it's stored).

Sign in to participate in the conversation
📟🐱 GlitchCat

A small, community‐oriented Mastodon‐compatible Fediverse (GlitchSoc) instance managed as a joint venture between the cat and KIBI families.