RFR: JDK-8276422 Add command-line option to disable finalization [v2]
Stuart Marks
smarks at openjdk.java.net
Thu Nov 18 19:30:49 UTC 2021
On Thu, 18 Nov 2021 15:05:49 GMT, Peter Levart <plevart at openjdk.org> wrote:
>> Or, you could move the static initialization block that statrts the finalizer thread into the Finalizer.FinalizerThread class itself and then arrange for that class to be initialized explicitly immediately after the Finalizer class, but conditionally, only if the option to disable finalization was not specified...
>> This way the Finalizer class could still be initialized early, but the thread would not be started if it is not needed.
>
> If you then need this "flag" in the assert of registerFinalizer and runFinalization, you could use unsafe.shouldBeInitialized(Finalizer.FinalizerThread.class) as a means to find out whether the flag was set or not...
The disable-finalization feature is a bit more than experimental. The goal is to provide a faithful representation of what the system will look like when finalization is removed. Of course most of that is objects' `finalize` methods not being called, but it also includes having no finalizer thread running, as well as having `runFinalization` (a public API) do nothing at all. Thus I think it's useful to have the flag visible to Java.
-------------
PR: https://git.openjdk.java.net/jdk/pull/6442
More information about the core-libs-dev
mailing list