tutorial on using Cleaner-based finalization
mandy.chung at oracle.com
Thu May 4 15:32:50 UTC 2017
> On May 3, 2017, at 11:16 PM, Peter Levart <peter.levart at gmail.com> wrote:
> Hi Rick,
> Allow me to join the discussion...
> On 05/04/2017 04:21 AM, Rick Hillegas wrote:
>> Thanks, Roger. That is a helpful example.
>> Derby is a component which can be quiesced and unloaded on resource-constrained platforms, then re-loaded when resources free up. Unloading means garbage collecting all the classloaders created by the component so that, at the end, not a single scrap of Derby code remains loaded. Has the Cleaner pattern been tested under these kinds of conditions? Can you point me at a Cleaner-based library which successfully unloads and reloads itself without leaking classloaders?
> Can you point me to a place in Derby code where you are currently using finalize() method for your purpose and I'll try to show you how to convert this to Cleaner API...
> I'm surprised that you actually need finalize() in Derby. Isn't this pure Java code? Usually finalize() is needed in situations where there's some non-Java resource which has to be cleaned-up when all the references to some Java object that represents it are gone. I'm curious what you need to clean in a pure Java library.
Please include me for the pointer to Derby code too. This can be used serving as examples to migrate away from use of finalizers. We also hope to do that in JDK to set up more examples.
More information about the core-libs-dev