diff --git a/src/hotspot/share/prims/jvmtiEnvBase.cpp b/src/hotspot/share/prims/jvmtiEnvBase.cpp index 9b4ac85f220..4c9e3d67d5f 100644 --- a/src/hotspot/share/prims/jvmtiEnvBase.cpp +++ b/src/hotspot/share/prims/jvmtiEnvBase.cpp @@ -2312,6 +2312,7 @@ SetForceEarlyReturn::doit(Thread *target) { // Set pending step flag for this early return. // It is cleared when next step event is posted. _state->set_pending_step_for_earlyret(); + _state->invalidate_cur_stack_depth(); } void diff --git a/src/hotspot/share/prims/jvmtiThreadState.cpp b/src/hotspot/share/prims/jvmtiThreadState.cpp index 5f496bbc6d4..a1bcf3a0137 100644 --- a/src/hotspot/share/prims/jvmtiThreadState.cpp +++ b/src/hotspot/share/prims/jvmtiThreadState.cpp @@ -409,7 +409,8 @@ int JvmtiThreadState::cur_stack_depth() { guarantee(get_thread()->is_handshake_safe_for(current), "must be current thread or direct handshake"); - if (!is_interp_only_mode() || _cur_stack_depth == UNKNOWN_STACK_DEPTH) { + if (!is_interp_only_mode() || _cur_stack_depth == UNKNOWN_STACK_DEPTH + || is_pending_step_for_earlyret() || is_pending_step_for_popframe()) { _cur_stack_depth = count_frames(); } else { #ifdef ASSERT @@ -474,7 +475,7 @@ void JvmtiThreadState::process_pending_step_for_popframe() { void JvmtiThreadState::update_for_pop_top_frame() { // remove any frame pop notification request for the top frame // in any environment - int popframe_number = cur_stack_depth(); + int popframe_number = count_frames(); { JvmtiEnvThreadStateIterator it(this); for (JvmtiEnvThreadState* ets = it.first(); ets != nullptr; ets = it.next(ets)) {