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

Remove deprecated Runtime::runFinalizersOnExit and System::runFinalizersOnExit

    XMLWordPrintable

Details

    • CSR
    • Resolution: Approved
    • P3
    • 11
    • core-libs
    • None
    • source, binary, behavioral
    • medium
    • Hide
      Existing code calling `System::runFinalizersOnExit` or `Runtime::runFinalizersOnExit` will fail to compile and fail with `NoSuchMethodError` at runtime.

      We analyzed of 345587 maven central artifacts few years ago [1]. Less than 0.013% of JAR files referencing `System.runFinalizersOnExit`. In addition, a newer version of most of those impacted maven artifacts no longer calls it. It is believed that the compatibility risk should be low.
      We put down medium compatibility risk in the CSR as the data represents
      a big representative libraries but not all.

      [1] https://bugs.openjdk.java.net/browse/JDK-4240589?focusedCommentId=14152485&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-14152485
      Show
      Existing code calling `System::runFinalizersOnExit` or `Runtime::runFinalizersOnExit` will fail to compile and fail with `NoSuchMethodError` at runtime. We analyzed of 345587 maven central artifacts few years ago [1]. Less than 0.013% of JAR files referencing `System.runFinalizersOnExit`. In addition, a newer version of most of those impacted maven artifacts no longer calls it. It is believed that the compatibility risk should be low. We put down medium compatibility risk in the CSR as the data represents a big representative libraries but not all. [1] https://bugs.openjdk.java.net/browse/JDK-4240589?focusedCommentId=14152485&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-14152485
    • Java API
    • SE

    Description

      Summary

      Remove deprecated Runtime::runFinalizersOnExit and System::runFinalizersOnExit methods

      Problem

      Runtime::runFinalizersOnExit is inherently unsafe. It has been deprecated since 1.2. It has also been deprecated for removal in Java SE 9.

      Calling this method may result in finalizers being called on live objects while other threads are concurrently manipulating those objects, resulting in erratic behavior or deadlock. While this problem could be prevented if the class whose objects are being finalized were coded to "defend against" this call, most programmers do not defend against it. They assume that an object is dead at the time that its finalizer is called.

      Solution

      Remove Runtime::runFinalizersOnExit and System::runFinalizersOnExit methods.

      Update the spec of Runtime::addShutdownHook, Runtime::exit, Runtime::halt describing the shutdown sequence and drop the phase about invoking all finalizers before VM halts.

      Specification

      See attached specdiffs

      Attachments

        1. Runtime-report.html
          92 kB
          Mandy Chung
        2. System-report.html
          88 kB
          Mandy Chung

        Issue Links

          Activity

            People

              mchung Mandy Chung
              mchung Mandy Chung
              Alan Bateman, David Holmes, Stuart Marks
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: