src/share/vm/prims/jvmtiGetLoadedClasses.cpp

Print this page
rev 5327 : imported patch 8024423

@@ -260,24 +260,22 @@
   // we can only pass static methods.
 
   JvmtiGetLoadedClassesClosure closure;
   {
     // To get a consistent list of classes we need MultiArray_lock to ensure
-    // array classes aren't created, and SystemDictionary_lock to ensure that
-    // classes aren't added to the system dictionary,
+    // array classes aren't created.
+    // Do we need a lock while reading from the ClassLoaderDataGraph?
     MutexLocker ma(MultiArray_lock);
-    MutexLocker sd(SystemDictionary_lock);
 
     // First, count the classes
-    SystemDictionary::classes_do(&JvmtiGetLoadedClassesClosure::increment);
+    ClassLoaderDataGraph::classes_do(&JvmtiGetLoadedClassesClosure::increment);
     Universe::basic_type_classes_do(&JvmtiGetLoadedClassesClosure::increment);
     // Next, fill in the classes
     closure.allocate();
-    SystemDictionary::classes_do(&JvmtiGetLoadedClassesClosure::add);
+    
+    ClassLoaderDataGraph::classes_do(&JvmtiGetLoadedClassesClosure::add);
     Universe::basic_type_classes_do(&JvmtiGetLoadedClassesClosure::add);
-    // Drop the SystemDictionary_lock, so the results could be wrong from here,
-    // but we still have a snapshot.
   }
   // Post results
   jclass* result_list;
   jvmtiError err = env->Allocate(closure.get_count() * sizeof(jclass),
                                  (unsigned char**)&result_list);