Loosening requirements for super() invocation
Archie Cobbs
archie.cobbs at gmail.com
Wed Jan 18 02:46:28 UTC 2023
On Tue, Jan 17, 2023 at 8:03 PM Brian Goetz <brian.goetz at oracle.com> wrote:
> > * Register a listener.
>
> Basically, these behaviors don't mix well with extension.
>
To demonstrate how subtle the problems can be...
What typically happens when you register yourself as a listener? Usually
the class that is doing the registering just puts you into a HashSet.
No big deal, right?
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.
Hilarity (or worse) ensues...
-Archie
--
Archie L. Cobbs
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/amber-dev/attachments/20230117/01108387/attachment-0001.htm>
More information about the amber-dev
mailing list