8217846: [Graal] vmTestbase/nsk/jdi/VirtualMachine/instanceCounts/instancecounts003/instancecounts003.java crash
authorhseigel
Wed, 08 May 2019 10:08:11 -0400
changeset 54761 a5b33a664b4f
parent 54760 57fbbef65a26
child 54762 64d9a4d582bc
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
src/hotspot/share/oops/objArrayKlass.cpp
src/hotspot/share/oops/typeArrayKlass.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;
 }
 
--- 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;
 }