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

Roger Riggs Roger.Riggs at Oracle.com
Wed Oct 14 17:43:48 UTC 2015


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.
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