RFR JDK-8185582, Update Zip implementation to use Cleaner, not finalizers

Florian Weimer fw at deneb.enyo.de
Sat Oct 28 20:22:17 UTC 2017

* Xueming Shen:

> It might be possible to try-catch to expect Cleaner.register might
> fail, but I doubt it's really necessary here and it is the
> recommended usage of Cleaner?

That is actually why I posted this. 8-)

For similar functionality in other languages, it is often necessary to
perform all the required allocations for cleanup registration upfront,
then allocate the resource, and finally install it in the cleanup

A straightforward translation to the Cleaner facility and the
CleaningExample in the documentation would not allocate the
state-to-be-cleaned in the State constructor, but in a separate method
which is called after Cleaner.register().  But I don't know if this
could run into any concurrency issues.

More information about the core-libs-dev mailing list