# HG changeset patch # User hseigel # Date 1557324491 14400 # Node ID a5b33a664b4f1fe00027c76b61928d0772679e33 # Parent 57fbbef65a26f4da889423f521888537c908c34f 8217846: [Graal] vmTestbase/nsk/jdi/VirtualMachine/instanceCounts/instancecounts003/instancecounts003.java crash Summary: Make sure the array calls's mirror was successfully created before putting the array class on its class loader data list Reviewed-by: lfoltan, coleenp diff -r 57fbbef65a26 -r a5b33a664b4f src/hotspot/share/oops/objArrayKlass.cpp --- a/src/hotspot/share/oops/objArrayKlass.cpp Wed May 08 09:38:58 2019 -0400 +++ b/src/hotspot/share/oops/objArrayKlass.cpp Wed May 08 10:08:11 2019 -0400 @@ -126,17 +126,19 @@ // Initialize instance variables ObjArrayKlass* oak = ObjArrayKlass::allocate(loader_data, n, element_klass, name, CHECK_0); - // Add all classes to our internal class loader list here, - // including classes in the bootstrap (NULL) class loader. - // GC walks these as strong roots. - loader_data->add_class(oak); - ModuleEntry* module = oak->module(); assert(module != NULL, "No module entry for array"); // Call complete_create_array_klass after all instance variables has been initialized. ArrayKlass::complete_create_array_klass(oak, super_klass, module, CHECK_0); + // Add all classes to our internal class loader list here, + // including classes in the bootstrap (NULL) class loader. + // Do this step after creating the mirror so that if the + // mirror creation fails, loaded_classes_do() doesn't find + // an array class without a mirror. + loader_data->add_class(oak); + return oak; } diff -r 57fbbef65a26 -r a5b33a664b4f src/hotspot/share/oops/typeArrayKlass.cpp --- a/src/hotspot/share/oops/typeArrayKlass.cpp Wed May 08 09:38:58 2019 -0400 +++ b/src/hotspot/share/oops/typeArrayKlass.cpp Wed May 08 10:08:11 2019 -0400 @@ -55,14 +55,16 @@ TypeArrayKlass* ak = TypeArrayKlass::allocate(null_loader_data, type, sym, CHECK_NULL); + // Call complete_create_array_klass after all instance variables have been initialized. + complete_create_array_klass(ak, ak->super(), ModuleEntryTable::javabase_moduleEntry(), CHECK_NULL); + // Add all classes to our internal class loader list here, // including classes in the bootstrap (NULL) class loader. - // GC walks these as strong roots. + // Do this step after creating the mirror so that if the + // mirror creation fails, loaded_classes_do() doesn't find + // an array class without a mirror. null_loader_data->add_class(ak); - // Call complete_create_array_klass after all instance variables have been initialized. - complete_create_array_klass(ak, ak->super(), ModuleEntryTable::javabase_moduleEntry(), CHECK_NULL); - return ak; }