Hi Mandy,

On 19/11/2021 6:16 am, Mandy Chung wrote:
On Thu, 18 Nov 2021 06:49:03 GMT, Kim Barrett <kbarr...@openjdk.org> wrote:

src/hotspot/share/prims/jvm.cpp line 694:

692:
693: JVM_ENTRY(jboolean, JVM_IsFinalizationEnabled(JNIEnv * env))
694: return InstanceKlass::finalization_enabled() ? JNI_TRUE : JNI_FALSE;

missing indentation

I think this could just be `return InstanceKlass::finalization_enabled();`.  
There is lots of code in this file and elsewhere that assumes C++ `bool` 
converts to `jboolean` appropriately.

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).

The Finalizer class is initialized before initPhase1() happens. So to use a property the Holder class had to be introduced to be initialized after initPhase1().

There is always a choice of having the VM push up a system property to the Java code, or the Java code calling down to query the VM. The VM call seems simpler/cheaper/cleaner in this case.

Cheers,
David

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.

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

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

Reply via email to