RFR 9: 8138696 : java.lang.ref.Cleaner - an easy to use alternative to finalization

Chris Hegarty chris.hegarty at oracle.com
Thu Oct 15 10:47:19 UTC 2015


On 14 Oct 2015, at 18:43, Roger Riggs <Roger.Riggs at oracle.com> wrote:

> Hi Alan, Mandy,
> I looked at a few of the many uses of finalize and the likely changes.
> The zip Inflater and Deflater are relatively simple cases.
> Some finalizers are not used and can be removed.

It is not immediately clear to me. Are you saying that some
finalize() methods, like the ones on Inflater and Deflater,
are part of Java SE spec and should be deprecated in 9,
then removed in 10. While others, that are just
implementation, can be removed now?


> The sun.net.www.MeteredStream example subclasses PhantomCleanable to add the state and cleanup
> behavior.
> http://cr.openjdk.java.net/~rriggs/webrev-cleaning-finalizers/
> Some of the harder cases will take more time to disentangle the cleanup code.
> For example, ZipFile, and FileIn/OutputStream (Peter has prototyped this).
> Roger
> On 10/14/2015 10:23 AM, Alan Bateman wrote:
>> On 14/10/2015 15:03, Roger Riggs wrote:
>>> Hi Alan,
>>> So any user of the Cleaner can take advantage of the mechanism, for example in a different package or module.
>>> For example, Netbeans.
>> Cleaner + Cleanable need to be public of course so maybe we should wait for the examples that extend WeakCleanableRef or cast the Cleanable to a WeakCleanableRef before seeing if this is the right thing or not.
>> -Alan

More information about the core-libs-dev mailing list