RFR: JDK-8276422 Add command-line option to disable finalization

Kim Barrett kbarrett at openjdk.java.net
Thu Nov 18 07:19:37 UTC 2021


On Thu, 18 Nov 2021 01:34:36 GMT, Stuart Marks <smarks at openjdk.org> wrote:

> Pretty much what it says. The new option controls a static member in InstanceKlass that's consulted to determine whether the finalization machinery is activated for instances when a class is loaded. A new native method is added so that this state can be queried from Java. This is used to control whether a finalizer thread is created and to disable the `System` and `Runtime::runFinalization` methods. Includes tests for the above.

I only really reviewed the hotspot changes.

There is nothing here to make the various GCs take advantage of finalization being disabled.  Is the plan to leave that to followup changes?

src/hotspot/share/oops/instanceKlass.hpp line 338:

> 336: 
> 337:   // Queries finalization state
> 338:   static bool finalization_enabled() { return _finalization_enabled; }

Predicate functions like this are often named "is_xxx"; that idiom is common in this class.

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

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

Changes requested by kbarrett (Reviewer).

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



More information about the build-dev mailing list