< prev index next > test/hotspot/gtest/classfile/test_placeholders.cpp
Print this page
ClassLoaderData* loader_data = ClassLoaderData::the_null_class_loader_data();
{
MutexLocker ml(THREAD, SystemDictionary_lock);
! PlaceholderTable::classloadAction super_action = PlaceholderTable::LOAD_SUPER;
PlaceholderTable::classloadAction define_action = PlaceholderTable::DEFINE_CLASS;
// DefineClass A and D
PlaceholderTable::find_and_add(A, loader_data, define_action, nullptr, THREAD);
PlaceholderTable::find_and_add(D, loader_data, define_action, nullptr, T2);
ClassLoaderData* loader_data = ClassLoaderData::the_null_class_loader_data();
{
MutexLocker ml(THREAD, SystemDictionary_lock);
! PlaceholderTable::classloadAction super_action = PlaceholderTable::DETECT_CIRCULARITY;
PlaceholderTable::classloadAction define_action = PlaceholderTable::DEFINE_CLASS;
// DefineClass A and D
PlaceholderTable::find_and_add(A, loader_data, define_action, nullptr, THREAD);
PlaceholderTable::find_and_add(D, loader_data, define_action, nullptr, T2);
PlaceholderTable::find_and_add(A, loader_data, super_action, super, THREAD);
PlaceholderTable::find_and_add(D, loader_data, super_action, super, T2);
// Another thread comes in and finds A loading Super
PlaceholderEntry* placeholder = PlaceholderTable::get_entry(A, loader_data);
! SymbolHandle supername = placeholder->supername();
// Other thread is done before handle_parallel_super_load
PlaceholderTable::find_and_remove(A, loader_data, super_action, THREAD);
// if THREAD drops reference to supername (loading failed or class unloaded), we're left with
PlaceholderTable::find_and_add(A, loader_data, super_action, super, THREAD);
PlaceholderTable::find_and_add(D, loader_data, super_action, super, T2);
// Another thread comes in and finds A loading Super
PlaceholderEntry* placeholder = PlaceholderTable::get_entry(A, loader_data);
! SymbolHandle supername = placeholder->next_klass_name();
// Other thread is done before handle_parallel_super_load
PlaceholderTable::find_and_remove(A, loader_data, super_action, THREAD);
// if THREAD drops reference to supername (loading failed or class unloaded), we're left with
PlaceholderTable::find_and_add(A, loader_data, super_action, supername, T2);
// Refcount should be 3: one in table for class A, one in table for class D
// and one locally with SymbolHandle keeping it alive
placeholder = PlaceholderTable::get_entry(A, loader_data);
! supername = placeholder->supername();
EXPECT_EQ(super->refcount(), 3) << "super class name refcount should be 3";
// Second thread's done too
PlaceholderTable::find_and_remove(D, loader_data, super_action, T2);
PlaceholderTable::find_and_add(A, loader_data, super_action, supername, T2);
// Refcount should be 3: one in table for class A, one in table for class D
// and one locally with SymbolHandle keeping it alive
placeholder = PlaceholderTable::get_entry(A, loader_data);
! supername = placeholder->next_klass_name();
EXPECT_EQ(super->refcount(), 3) << "super class name refcount should be 3";
// Second thread's done too
PlaceholderTable::find_and_remove(D, loader_data, super_action, T2);
< prev index next >