RFR 9: 8138696 : java.lang.ref.Cleaner - an easy to use alternative to finalization
Roger.Riggs at Oracle.com
Wed Oct 14 14:03:36 UTC 2015
So any user of the Cleaner can take advantage of the mechanism, for
example in a different package or module.
For example, Netbeans.
On 10/14/2015 10:01 AM, Alan Bateman wrote:
> On 14/10/2015 14:54, Roger Riggs wrote:
>> Being able to subclass the XXXCleanable classes allows more efficient
>> implementation of the cleaners
>> in both size and performance. The subclass adds the necessary state
>> for the cleanup and implements
>> the performCleanup method. Only a single object is created (and
>> gc'd), reducing the size of headers
>> and cross references between separate objects. Only the
>> performCleanup method is overridable to
>> maintain the robustness of the Cleaner implementation.
>> If the XXXCleaner classes are not subclassed, a separate object is
>> needed for the state and behavior.
>> Either that extra object is created by the binding if lambda is used,
>> or by the class needing the cleanup.
>> It is not a big cost but is proposed to optimize the design and
>> Peter's email  provided another description of the use case for
>> I'm working on a webrev to show how the Cleaner would be used instead
>> of finalizers
>> and it will show use use of both lambdas and explicit cleanup classes.
> No issue with sub-classing for the implementation, it's just not clear
> why they need to be in the public API.
More information about the core-libs-dev