JDK-8153133 : Thread.dumpStack() can use StackWalker
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.lang
  • Affected Version: 9
  • Priority: P4
  • Status: Resolved
  • Resolution: Won't Fix
  • Submitted: 2016-03-30
  • Updated: 2021-11-09
  • Resolved: 2021-11-09
Related Reports
Relates :  
Relates :  
Description
Unlike Throwable, Thread.dumpStack() is used purely for troubleshooting and not performance critical.  Therefore, Thread.dumpStack() could use the StackWalker API to output the stack trace, instead of constructing a throw-away Exception.

Comments
Marking as won't fix.
09-11-2021

A PR was raised proposing an implementation of this change https://github.com/openjdk/jdk/pull/6292. As noted in that PR, it became necessary to have a fallback in this code to continue using an Exception instance to print the stacktrace. It was decided that a change like this would not bring any benefit and it would be better to close this enhancement request as won't fix.
09-11-2021

It would be nice to see Thread::dumpStack to call StackWalker. Perhaps Thread::getStackTrace can be converted too.
20-06-2017