--- a/hotspot/src/share/vm/oops/cpCache.cpp Mon Jun 23 14:20:20 2014 -0700
+++ b/hotspot/src/share/vm/oops/cpCache.cpp Wed Jun 25 20:41:16 2014 -0700
@@ -287,7 +287,9 @@
// the lock, so that when the losing writer returns, he can use the linked
// cache entry.
- MonitorLockerEx ml(cpool->lock());
+ // Use the lock from the metaspace for this, which cannot stop for safepoint.
+ Mutex* metaspace_lock = cpool->pool_holder()->class_loader_data()->metaspace_lock();
+ MutexLockerEx ml(metaspace_lock, Mutex::_no_safepoint_check_flag);
if (!is_f1_null()) {
return;
}