* src/vm/classcache.c (classcache_foreach_loaded_class): New function.
authoredwin <none@none>
Sat, 16 Dec 2006 21:14:23 +0000 (21:14 +0000)
committeredwin <none@none>
Sat, 16 Dec 2006 21:14:23 +0000 (21:14 +0000)
* src/vm/classcache.h (classcache_foreach_loaded_class): Likewise.
(classcache_foreach_functionptr_t): New typedef.

src/vm/classcache.c
src/vm/classcache.h

index 1ff561e2a16d9d1c96cfb46fb475514058512982..6b6ef48f362febfd1b685a2496b60b092ae6633f 100644 (file)
@@ -28,7 +28,7 @@
 
    Changes: Christian Thalinger
 
-   $Id: classcache.c 5192 2006-07-31 14:21:15Z twisti $
+   $Id: classcache.c 6209 2006-12-16 21:14:23Z edwin $
 
 */
 
@@ -1455,6 +1455,48 @@ void classcache_get_loaded_classes(s4 *class_count_ptr,
 #endif /* defined(ENABLE_JVMTI) */
 
 
+/* classcache_foreach_loaded_class *********************************************
+
+   Calls the given function for each loaded class.
+
+*******************************************************************************/
+
+void classcache_foreach_loaded_class(classcache_foreach_functionptr_t func,
+                                                                        void *data)
+{
+       classcache_name_entry   *en;
+       classcache_class_entry  *clsen;
+       s4                       i;
+
+       CLASSCACHE_LOCK();
+
+       /* look in every slot of the hashtable */
+
+       for (i = 0; i < hashtable_classcache.size; i++) {
+               /* iterate over hashlink */
+
+               for (en = hashtable_classcache.ptr[i]; en != NULL; en = en->hashlink) {
+                       /* filter pseudo classes $NEW$, $NULL$, $ARRAYSTUB$ out */
+
+                       if (en->name->text[0] == '$')
+                               continue;
+
+                       /* iterate over classes with same name */
+
+                       for (clsen = en->classes; clsen != NULL; clsen = clsen->next) {
+                               /* get only loaded classes */
+
+                               if (clsen->classobj != NULL) {
+                                       (*func)(clsen->classobj, data);
+                               }
+                       }
+               }
+       }
+
+       CLASSCACHE_UNLOCK();
+}
+
+
 /*============================================================================*/
 /* DEBUG DUMPS                                                                */
 /*============================================================================*/
index e8a471e020e01125ef88cc70d187cf6ea5325cb4..9457aa71bf8c3bbb0a7aabbe759e9e631ced5c6b 100644 (file)
@@ -28,7 +28,7 @@
 
    Changes: Christian Thalinger
 
-   $Id: classcache.h 5192 2006-07-31 14:21:15Z twisti $
+   $Id: classcache.h 6209 2006-12-16 21:14:23Z edwin $
 
 */
 
@@ -123,6 +123,11 @@ struct classcache_loader_entry
 };
 
 
+/* callback function type for  classcache_foreach_loaded_class */
+
+typedef void (*classcache_foreach_functionptr_t)(classinfo *, void *);
+
+
 /* function prototypes ********************************************************/
 
 /* initialize the loaded class cache */
@@ -145,6 +150,9 @@ bool classcache_add_constraints_for_params(classloader *a,classloader *b,
 
 s4 classcache_get_loaded_class_count(void);
 
+void classcache_foreach_loaded_class(classcache_foreach_functionptr_t func,
+                                                                        void *data);
+
 #if defined(ENABLE_JVMTI)
 void classcache_get_loaded_classes(s4 *class_count_ptr,
                                                                   classinfo ***classes_ptr);