On Dec 8, 2015, at 3:09 AM, David Holmes <david.hol...@oracle.com> wrote: > > Question: what happens if an object is registered simultaneously with > multiple Cleaners? Do we need to warn the user against that?
Aside: I like David's suggested "action" terminology. > Question: what happens if an object is registered simultaneously with > multiple Cleaners? Do we need to warn the user against that? Registering an object with multiple Cleaners, or even the same Cleaner multiple times, is not a problem, so long as the various cleanup actions can cope with that. This is even expected to occur in practice. Consider the conversion of a class hierarchy away from using finalize() to instead using Cleaners. A base class may register a cleanup action for the state associated with that (base) class. A derived class may independently register a cleanup action for the additional state associated with that derived class. The derived class's cleanup action might be registered with the same or a different Cleaner than that used by the base class.