This bug was found when diagnosing JDK-8316131
Handle CDSProtectionDomain::get_shared_protection_domain(Handle class_loader,
int shared_path_index,
Handle url,
TRAPS) {
Handle protection_domain;
if (shared_protection_domain(shared_path_index) == nullptr) {
Handle pd = get_protection_domain_from_classloader(class_loader, url, THREAD); <<<<< HERE
atomic_set_shared_protection_domain(shared_path_index, pd());
}
// Acquire from the cache because if another thread beats the current one to
// set the shared protection_domain and the atomic_set fails, the current thread
// needs to get the updated protection_domain from the cache.
protection_domain = Handle(THREAD, shared_protection_domain(shared_path_index));
assert(protection_domain.not_null(), "sanity"); <<<<< HERE
return protection_domain;
}
When we are really low on heap memory, the get_protection_domain_from_classloader() call may fail. Instead of THREAD, we should pass CHECK so that the exception is propagated properly.