--- old/src/share/vm/runtime/jniHandles.cpp 2017-07-20 18:58:53.930162810 -0400 +++ new/src/share/vm/runtime/jniHandles.cpp 2017-07-20 18:58:53.826157434 -0400 @@ -276,7 +276,7 @@ void JNIHandleBlock::zap() { // Zap block values - _top = 0; + _top = 0; for (int index = 0; index < block_size_in_oops; index++) { _handles[index] = badJNIHandle; } @@ -314,7 +314,7 @@ _block_free_list = _block_free_list->_next; } } - block->_top = 0; + block->_top = 0; block->_next = NULL; block->_pop_frame_link = NULL; block->_planned_capacity = block_size_in_oops; @@ -444,6 +444,15 @@ assert(current->_last == NULL, "only first block should have _last set"); assert(current->_free_list == NULL, "only first block should have _free_list set"); + if (current->_top == 0) { + // All blocks after the first clear trailing block are already cleared. +#ifdef ASSERT + for (current = current->_next; current != NULL; current = current->_next) { + assert(current->_top == 0, "trailing blocks must already be cleared"); + } +#endif + break; + } current->_top = 0; if (ZapJNIHandleArea) current->zap(); } --- old/src/share/vm/runtime/jniHandles.hpp 2017-07-20 18:58:54.450189698 -0400 +++ new/src/share/vm/runtime/jniHandles.hpp 2017-07-20 18:58:54.346184318 -0400 @@ -149,11 +149,6 @@ // Fill block with bad_handle values void zap(); - protected: - // No more handles in the both the current and following blocks - void clear() { _top = 0; } - - private: // Free list computation void rebuild_free_list();