--- old/src/hotspot/share/prims/jniCheck.cpp 2017-12-10 00:36:35.934971682 -0500 +++ new/src/hotspot/share/prims/jniCheck.cpp 2017-12-10 00:36:33.842852518 -0500 @@ -826,7 +826,10 @@ } jint result = UNCHECKED()->EnsureLocalCapacity(env, capacity); if (result == JNI_OK) { - add_planned_handle_capacity(thr->active_handles(), capacity); + // increase local ref capacity if needed + if ((size_t)capacity > thr->active_handles()->get_planned_capacity()) { + add_planned_handle_capacity(thr->active_handles(), capacity); + } } functionExit(thr); return result;