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
*/
- csr of
-
JDK-8205132 Degrade Thread.countStackFrames() to throw UOE
- Resolved