--- old/src/hotspot/share/services/heapDumper.cpp Tue Nov 21 15:11:22 2017 +++ new/src/hotspot/share/services/heapDumper.cpp Tue Nov 21 15:11:22 2017 @@ -39,6 +39,8 @@ #include "runtime/jniHandles.hpp" #include "runtime/os.hpp" #include "runtime/reflectionUtils.hpp" +#include "runtime/thread.inline.hpp" +#include "runtime/threadSMR.hpp" #include "runtime/vframe.hpp" #include "runtime/vmThread.hpp" #include "runtime/vm_operations.hpp" @@ -1895,7 +1897,7 @@ _stack_traces = NEW_C_HEAP_ARRAY(ThreadStackTrace*, Threads::number_of_threads(), mtInternal); int frame_serial_num = 0; - for (JavaThread* thread = Threads::first(); thread != NULL ; thread = thread->next()) { + for (JavaThreadIteratorWithHandle jtiwh; JavaThread *thread = jtiwh.next(); ) { oop threadObj = thread->threadObj(); if (threadObj != NULL && !thread->is_exiting() && !thread->is_hidden_from_external_view()) { // dump thread stack trace