<div dir="ltr"><div dir="ltr">On Tue, Jan 17, 2023 at 8:03 PM Brian Goetz <<a href="mailto:brian.goetz@oracle.com">brian.goetz@oracle.com</a>> wrote:</div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">> * Register a listener.<br>
<br>Basically, these behaviors don't mix well with extension.<br></blockquote><div><br></div><div>To demonstrate how subtle the problems can be...</div><div><br></div><div>What typically happens when you register yourself as a listener? Usually the class that is doing the registering just puts you into a HashSet.</div><div><br></div><div>No big deal, right?<br></div><div><br></div><div>Except adding you to a HashSet means invoking hashCode()... which, if overridden by the subclass, is going to produce the wrong value because it's being calculated from uninitialized fields. So you end up in the wrong hash bucket.</div><div><br></div><div>Hilarity (or worse) ensues...</div><div><br></div><div>-Archie<br></div></div><br>-- <br><div dir="ltr" class="gmail_signature">Archie L. Cobbs<br></div></div>