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

Remove Thread.countStackFrames

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P4 P4
    • 22
    • core-libs
    • None
    • source, binary
    • minimal
    • Hide
      The method throws UOE since Java 14. It's possible there is code somewhere that "wraps" a Thread and delegates all methods. This code will no longer compile without change. Code compiled to older releases will continue to run, except if wrapper.countStackFrame is called, in which case NoSuchMethodError will be thrown instead of UnsupportedOperationException.
      Show
      The method throws UOE since Java 14. It's possible there is code somewhere that "wraps" a Thread and delegates all methods. This code will no longer compile without change. Code compiled to older releases will continue to run, except if wrapper.countStackFrame is called, in which case NoSuchMethodError will be thrown instead of UnsupportedOperationException.
    • Java API
    • SE

      Summary

      Remove method java.lang.Thread.countStackFrames().

      Problem

      Thread.countStackFrames is an ill-defined method that dates from JDK 1.0 for counting the stack frames of a suspended Thread (it did not support the operation on the current thread). The method has been deprecated since JDK 1.2 (1998). More recently, the method was deprecated for removal in Java 9, and re-specified/degraded in Java 14 to throw UnsupportedOperationException unconditionally.

      java.lang.StackWalker was added in Java 9 support stack walking needs. This provides a much better API for anything that might need to count the current thread's stack frames.

      A corpus analysis of 30M classes in 131k artifacts found only 1 usages to this method. The 1 usage appears to be a class that just wraps all methods, it doesn't actually make use of it.

      It is time to finally remove this method.

      Solution

      Remove the method.

      Specification

      Remove method java.lang.Thread.countStackFrames().

            alanb Alan Bateman
            alanb Alan Bateman
            Stuart Marks
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: