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

Remove deprecated Runtime::runFinalizersOnExit and System::runFinalizersOnExit

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P3 P3
    • 11
    • 11
    • core-libs
    • b03

      Runtime::runFinalizersOnExit is inherently unsafe [1] and has been deprecated since 1.2. It has been deprecated for removal in Java SE 9.

      It 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.

      Further, the call is not "thread-safe" in the sense that it sets a VM-global flag. This forces every class with a finalizer to defend against the finalization of live objects!

      [1] https://docs.oracle.com/javase/9/docs/api/java/lang/doc-files/threadPrimitiveDeprecation.html

            mchung Mandy Chung (Inactive)
            mchung Mandy Chung (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: