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

Degrade Thread.countStackFrames() to throw UOE

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P4 P4
    • 14
    • core-libs
    • None
    • binary
    • low
    • Hide
      This method has always been ill-defined and has required the thread to be suspended so we expect the compatibility risk of removing it to be low. A regression in JDK 10/11/12 accidentally allows the method to be invoked on the current thread without suspension, we don't expect too many developers to have discovered this bug. The StackWalker API has been available since Java SE 9 and is a better choice for stack walking needs.
      Show
      This method has always been ill-defined and has required the thread to be suspended so we expect the compatibility risk of removing it to be low. A regression in JDK 10/11/12 accidentally allows the method to be invoked on the current thread without suspension, we don't expect too many developers to have discovered this bug. The StackWalker API has been available since Java SE 9 and is a better choice for stack walking needs.
    • Java API
    • SE

      Summary

      Re-specify Thread::countStackFrames to unconditionally throw UnsupportedOperationException in advance of removing the method in a future release. The method has been deprecated since Java SE 1.2, and deprecated for removal since Java SE 9.

      Problem

      This method has always been ill-defined and useless. It requires the target thread to be suspended, an operation that is inherently deadlock prone. The StackWalker API has provided a better solution for stack walking needs since Java SE 9.

      Solution

      Re-specify Thread::countStackFrames to unconditionally throw UnsupportedOperationException.

      Specification

      Change specification to:

          /**
           * Throws {@code UnsupportedOperationException}.
           *
           * @return     nothing
           *
           * @deprecated This method was originally designed to count the number of
           *             stack frames but the results were never well-defined and it
           *             depended on thread-suspension.
           *             This method is subject to removal in a future version of Java SE.
           * @see        StackWalker
           */

            alanb Alan Bateman
            smarks Stuart Marks
            Daniel Daugherty, David Holmes, Mandy Chung, Mark Reinhold, Stuart Marks
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: