From: Mathieu Chartier Date: Mon, 12 Oct 2015 22:06:16 +0000 (-0700) Subject: Avoid visiting find array class cache as roots X-Git-Tag: android-x86-7.1-r1~889^2~168^2 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=6cfc2c086c47342fd8f5cb09f565979333066473;p=android-x86%2Fart.git Avoid visiting find array class cache as roots If we visit the find array class cache as roots it will prevent unloading for any array classes in the cache. This is not ideal since it may take a long time for the entries to get replaced. Also added a missed exception check in getDeclaredClasses. Bug: 22720414 Change-Id: Id34557fd034b3e3967ef629301ee251931937849 --- diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc index 5ff4bc162..370ea5cfa 100644 --- a/runtime/class_linker.cc +++ b/runtime/class_linker.cc @@ -1023,9 +1023,9 @@ void ClassLinker::VisitRoots(RootVisitor* visitor, VisitRootFlags flags) { class_roots_.VisitRootIfNonNull(visitor, RootInfo(kRootVMInternal)); VisitClassRoots(visitor, flags); array_iftable_.VisitRootIfNonNull(visitor, RootInfo(kRootVMInternal)); - for (GcRoot& root : find_array_class_cache_) { - root.VisitRootIfNonNull(visitor, RootInfo(kRootVMInternal)); - } + // Instead of visiting the find_array_class_cache_ drop it so that it doesn't prevent class + // unloading if we are marking roots. + DropFindArrayClassCache(); } class VisitClassLoaderClassesVisitor : public ClassLoaderVisitor { diff --git a/runtime/native/java_lang_Class.cc b/runtime/native/java_lang_Class.cc index 5da15df25..3a73900ef 100644 --- a/runtime/native/java_lang_Class.cc +++ b/runtime/native/java_lang_Class.cc @@ -522,6 +522,10 @@ static jobjectArray Class_getDeclaredClasses(JNIEnv* env, jobject javaThis) { } if (classes == nullptr) { // Return an empty array instead of a null pointer. + if (soa.Self()->IsExceptionPending()) { + // Pending exception from GetDeclaredClasses. + return nullptr; + } mirror::Class* class_class = mirror::Class::GetJavaLangClass(); mirror::Class* class_array_class = Runtime::Current()->GetClassLinker()->FindArrayClass(soa.Self(), &class_class);