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

Degrade Thread.countStackFrames() to throw UOE

    XMLWordPrintable

    Details

    • Type: CSR
    • Status: Closed
    • Priority: P4
    • Resolution: Approved
    • Fix Version/s: 14
    • Component/s: core-libs
    • Labels:
      None
    • Subcomponent:
    • Compatibility Kind:
      binary
    • Compatibility Risk:
      low
    • Compatibility Risk Description:
      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.
    • Interface Kind:
      Java API
    • Scope:
      SE

      Description

      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
           */

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                Created:
                Updated:
                Resolved: