RFR 8080225 FileInput/OutputStream/FileChannel cleanup should be improved

Peter Levart peter.levart at gmail.com
Mon Dec 4 13:25:37 UTC 2017

Hi Rogger,

On 12/04/2017 02:17 PM, Peter Levart wrote:
> Hi Rogger,
> Interesting approach. Conditional finalization. You use finalization 
> to support cases where user overrides finalize() and/or close() and 
> Cleaner when he doesn't.
> I wonder if it is the right thing to use AltFinalizer when user 
> overrides finalize() method. In that case the method is probably not 
> empty and calls super.finalize() (if it is empty or doesn't call 
> super, user probably doesn't want the finalization to close the 
> stream) and so normal finalization applies. If you register 
> AltFinalizer for such case, close() will be called twice.

Ah, scrap that. I forgot that XXXStream.finalize() is now empty, so user 
overriding it and calling super does not in fact close the stream. You 
have to register AltFinalizer in that case. But now I wonder if the 
logic should still be 3-state and do the following:

- if user overrides finalize() - use AltFinalizer to call both: first 
finalize() and then close(); else
- if user overrides close() - use AltFinalizer to call close(); else
- use Cleaner

What do you think?

Regards, Peter

More information about the core-libs-dev mailing list