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

Add command-line option to disable finalization



    • Enhancement
    • Resolution: Fixed
    • P4
    • 18
    • None
    • core-libs
    • None
    • b27



        JEP 421 proposes to deprecate finalization for removal. As part of that work, it proposes a command-line option to disable finalization, so that developers can evaluate the effect on applications of not having finalization prior to its removal. This enhancement request covers the option.

        The option would be as follows:


        Legal values are "enabled" and "disabled". The default value in this release will be "enabled". In a future release, the default value will change to "disabled". However, both values will be accepted in the current release. The option "--finalization=disabled" on the command line will disable finalization, and "--finalization=enabled" will do nothing, as finalization is enabled by default. Other values will cause an error. Additional valid values may be added in the future.

        The effect of disabling finalization is as follows:

         * When a class is loaded into the JVM, the detection of a non-trivial finalize() method in the class is disabled. This prevents creation of finalization-related data structures by various GCs. This also disables the upcall to Finalizer::register, which prevents finalization-eligible objects from ever appearing on the heap. FinalReference processing will therefore not be done, and objects' finalize() methods won't be called.

         * The finalizer thread is not created.

         * Calls to `System::runFinalization` and `Runtime::runFinalization` have no effect.

        The Java Platform Specification, the JLS, and the "java" tool reference page will be updated to document this option. See the CSR JDK-8276773 for details.


          Issue Links



                smarks Stuart Marks
                smarks Stuart Marks
                0 Vote for this issue
                7 Start watching this issue