Finalizer being run while class still in use (escape analysis bug)
kim.barrett at oracle.com
Thu Oct 11 17:24:19 UTC 2018
> On Oct 11, 2018, at 5:29 AM, Andrew Haley <aph at redhat.com> wrote:
> On Wed, Oct 10, 2018 at 9:53 AM Kim Barrett <kim.barrett at oracle.com> wrote:
>> Finalization was deprecated in JDK 9 (*). There's an ongoing (though
>> progressing slowly) process of eliminating its usage in the JDK.
>> Sometime after that it may go away entirely, or perhaps require some
>> sort of explicit opt-in, making it possible to eliminate various GC
>> overheads associated with it.
>> (*) Use PhantomReference, or a helper like java.lang.ref.Cleaner.
>> Though that change the liveness question in this thread.
> It doesn't matter whether finalization is used or PhantomReferences,
> or whatever. The problem of "early" collection remains the same on
> every possible mechanism which relies on the GC to trigger cleanup, so
> reachabilityFence still has to be used to prevent early collectiona
> from happening.
Correct, and sorry for the “typo”; that was supposed to be
"Though that doesn’t change the liveness question in this thread."
More information about the jdk-dev