On Thu, 18 Nov 2021 21:19:44 GMT, Stuart Marks <sma...@openjdk.org> wrote:

>> One typical way for VM to pass the arguments to the library is via private 
>> system properties.   System::initPhase1 will save the VM properties in 
>> `jdk.internal.misc.VM` and filters out the private properties from the 
>> system properties returned from System::getProperties (see 
>> System::createProperties).
>> 
>> You can query the flag via 
>> `jdk.internal.misc.VM.getProperty("jdk.finalization.disabled")` for example.
>> 
>> I don't see any issue moving the Finalizer class initialization after 
>> initPhase1 since there is no finalizer during VM startup.
>
> I renamed the function to `is_finalization_enabled` per previous comment, and 
> I also made these cleanups.

Regarding using system properties, my initial prototype did this in the 
launcher, and it did run into the problem that the Finalizer class is 
initialized before system properties are available. That's why I created the 
Holder class, so that reading the property could be delayed until the first 
upcall to Finalizer::register. I suppose the initialization of Finalizer could 
be moved later, but that seems more invasive.

The flag needs to be available in the VM in order to avoid upcalls for 
instances-with-finalizers in the first place. Alan had 
[suggested](https://bugs.openjdk.java.net/browse/JDK-8276422?focusedCommentId=14456185&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-14456185)
 moving the argument processing into the VM, and David suggested putting the 
flag into InstanceKlass, which seems a sensible place to me. It's also 
reasonably accessible there to GC implementations, should they want to inspect 
it.

-------------

PR: https://git.openjdk.java.net/jdk/pull/6442

Reply via email to