[11] RFR JDK-8198249: Remove deprecated Runtime::runFinalizersOnExit and System::runFinalizersOnExit

David Holmes david.holmes at oracle.com
Fri Feb 16 02:11:50 UTC 2018

Hi Mandy,

Good to see this go. A few minor comments.

First I've added comments on the CSR as some of the doc changes don't 
read correctly.


This comment doesn't read correctly:

!     // won't be run.  Note that if a shutdown hook was registered
       // was called, the Shutdown class would have already been loaded
!     // (Runtime.addShutdownHook will load it).

delete "was called, "



This was a bit confusing. :) I wasn't at all sure you needed the 
COMPLETED state (which is really a HOOKS_HAVE_BEEN_STARTED state). But I 
see it allows for a second exit(<non-zero) call to be given preference 
to the initial exit() call (whether non-zero or not). That seems to 
maintain existing behaviour.



       private void remove() {
           synchronized (lock) {
               if (unfinalized == this) {
-                 if (this.next != null) {
                       unfinalized = this.next;
-                 } else {
-                     unfinalized = this.prev;
-                 }

This seems unrelated to this change. Is this the optimization Martin 

!        This method is used by both runFinalization.
          The former method invokes all pending finalizers, while the latter
          invokes all uninvoked finalizers if on-exit finalization has been

As Stuart said remove "both" in the modified line. But the following 
line also needs changing or deleting. As does the one after that:

  116        These two methods could have been implemented by offloading 
their work

as there are no longer two methods.

Otherwise this all seems okay. I was surprised none of this really 
impacted the VM. :)


On 16/02/2018 9:06 AM, mandy chung wrote:
> Runtime.runFinalizersOnExit has been deprecated since 1.2 (1998)
> and deprecated for removal in JDK 9.  We analyzed the maven central
> artifacts few years ago that show very few uses of it.  I also
> survey a recent version of most of the maven artifacts that references
> runFinalizatsOnExit no longer references it.  I propose to remove
> Runtime.runFinalizersOnExit and System.runFinalizersOnExit methods
> in JDK 11.
> CSR: https://bugs.openjdk.java.net/browse/JDK-8198250
> Webrev:
>    http://cr.openjdk.java.net/~mchung/jdk11/webrevs/8198249/webrev.00/
> Thanks
> Mandy
> [1] 
> http://mail.openjdk.java.net/pipermail/core-libs-dev/2015-January/031041.html 

More information about the core-libs-dev mailing list