Ensure GetLoadedClasses only returns 'Loaded' Classes.
Previously we could sometimes return references to retired classes
which is incorrect.
Bug: 62895303
Bug: 62902528
Test: ./test.py --host -j40
Change-Id: Ie4d2ce22fb29b13cbe358e552f05adb0e8687b1e
diff --git a/runtime/openjdkjvmti/ti_heap.cc b/runtime/openjdkjvmti/ti_heap.cc
index b3bc676..29658d9 100644
--- a/runtime/openjdkjvmti/ti_heap.cc
+++ b/runtime/openjdkjvmti/ti_heap.cc
@@ -1392,7 +1392,9 @@
bool operator()(art::ObjPtr<art::mirror::Class> klass)
OVERRIDE REQUIRES_SHARED(art::Locks::mutator_lock_) {
- classes_.push_back(self_->GetJniEnv()->AddLocalReference<jclass>(klass));
+ if (klass->IsLoaded() || klass->IsErroneous()) {
+ classes_.push_back(self_->GetJniEnv()->AddLocalReference<jclass>(klass));
+ }
return true;
}