Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8320409

Deprecate `RegisterFinalizersAtInit` option and code

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P4 P4
    • 22
    • hotspot
    • None
    • minimal
    • This option is ancient and has minimal (no?) observable use. With Finalization having been deprecated for removal in JDK18, cleaning up this code now seems like a good next step.
    • add/remove/modify command line option

      Summary

      The RegisterFinalizersAtInit option controls whether finalizers are registered after allocation or at return from the Object. constructor. The default is to register at the end of Object. and this has been the default for years.

      Problem

      Continuing to support the flag is counter to the increased Integrity push [0] and will be increasingly problematic when Project Valhalla merges in due to allowing larval objects to escape before they are frozen.

      [0] https://openjdk.org/jeps/8305968

      Solution

      Deprecate the option in JDK22, obsolete in JDK23, and expire in JDK24.

      Specification

      diff --git a/src/hotspot/share/runtime/arguments.cpp b/src/hotspot/share/runtime/arguments.cpp
      index dc1e15121b28..f6c1b0003e83 100644
      --- a/src/hotspot/share/runtime/arguments.cpp
      +++ b/src/hotspot/share/runtime/arguments.cpp
      @@ -509,6 +509,7 @@ static SpecialFlag const special_jvm_flags[] = {
         { "DynamicDumpSharedSpaces",      JDK_Version::jdk(18), JDK_Version::jdk(19), JDK_Version::undefined() },
         { "RequireSharedSpaces",          JDK_Version::jdk(18), JDK_Version::jdk(19), JDK_Version::undefined() },
         { "UseSharedSpaces",              JDK_Version::jdk(18), JDK_Version::jdk(19), JDK_Version::undefined() },
      +  { "RegisterFinalizersAtInit",     JDK_Version::jdk(22), JDK_Version::jdk(23), JDK_Version::jdk(24) },
      
         // --- Deprecated alias flags (see also aliased_jvm_flags) - sorted by obsolete_in then expired_in:
         { "DefaultMaxRAMFraction",        JDK_Version::jdk(8),  JDK_Version::undefined(), JDK_Version::undefined() },
      diff --git a/src/hotspot/share/runtime/globals.hpp b/src/hotspot/share/runtime/globals.hpp
      index 4ae156a773ea..f3c1ceab3d7f 100644
      --- a/src/hotspot/share/runtime/globals.hpp
      +++ b/src/hotspot/share/runtime/globals.hpp
      @@ -667,8 +667,8 @@ const int ObjectAlignmentInBytes = 8;
                 "Print JVM warnings to output stream")                            \
                                                                                   \
         product(bool, RegisterFinalizersAtInit, true,                             \
      -          "Register finalizable objects at end of Object.<init> or "        \
      -          "after allocation")                                               \
      +          "(Deprecated) Register finalizable objects at end of "            \
      +          "Object.<init> or after allocation")                              \
                                                                                   \
         develop(bool, RegisterReferences, true,                                   \
                 "Tell whether the VM should register soft/weak/final/phantom "    \

            heidinga Dan Heidinga
            heidinga Dan Heidinga
            Coleen Phillimore, David Holmes
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: