Mercurial > hg > truffle
diff src/share/vm/classfile/classLoaderData.cpp @ 12995:e64f1fe9756b
8024423: JVMTI: GetLoadedClasses doesn't enumerate anonymous classes
Summary: Rewrite of the getLoadedClasses() method implementation to include anonymous classes.
Reviewed-by: coleenp, sspitsyn
author | farvidsson |
---|---|
date | Thu, 24 Oct 2013 10:02:02 +0200 |
parents | 190899198332 |
children | 86e6d691f2e1 |
line wrap: on
line diff
--- a/src/share/vm/classfile/classLoaderData.cpp Wed Oct 23 10:24:28 2013 +0200 +++ b/src/share/vm/classfile/classLoaderData.cpp Thu Oct 24 10:02:02 2013 +0200 @@ -131,6 +131,17 @@ } } +void ClassLoaderData::loaded_classes_do(KlassClosure* klass_closure) { + // Lock to avoid classes being modified/added/removed during iteration + MutexLockerEx ml(metaspace_lock(), Mutex::_no_safepoint_check_flag); + for (Klass* k = _klasses; k != NULL; k = k->next_link()) { + // Do not filter ArrayKlass oops here... + if (k->oop_is_array() || (k->oop_is_instance() && InstanceKlass::cast(k)->is_loaded())) { + klass_closure->do_klass(k); + } + } +} + void ClassLoaderData::classes_do(void f(InstanceKlass*)) { for (Klass* k = _klasses; k != NULL; k = k->next_link()) { if (k->oop_is_instance()) { @@ -600,6 +611,12 @@ } } +void ClassLoaderDataGraph::loaded_classes_do(KlassClosure* klass_closure) { + for (ClassLoaderData* cld = _head; cld != NULL; cld = cld->next()) { + cld->loaded_classes_do(klass_closure); + } +} + void ClassLoaderDataGraph::classes_unloading_do(void f(Klass* const)) { assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint!"); for (ClassLoaderData* cld = _unloading; cld != NULL; cld = cld->next()) {