Support class lookup for InMemoryDexClassLoader
Setting up InMemoryDexClassLoader with 'null' as parent results in the
class loader not being able to load any boot classpath classes. This is
due to the fact that InMemoryDexClassLoader inherits class lookup from
BaseDexClassLoader which delegates it to ART, but ART rejects
InMemoryDexClassLoader as not supported.
Bug: 120603906
Bug: 120613979
Test: InMemoryDexClassLoaderTest
Change-Id: I3139b1bb343b5fc722bcf06f89a6f6a21a3c7c54
diff --git a/runtime/class_loader_utils.h b/runtime/class_loader_utils.h
index 945d659..ab28cf8 100644
--- a/runtime/class_loader_utils.h
+++ b/runtime/class_loader_utils.h
@@ -29,7 +29,7 @@
namespace art {
// Returns true if the given class loader is either a PathClassLoader or a DexClassLoader.
-// (they both have the same behaviour with respect to class lockup order)
+// (they both have the same behaviour with respect to class lookup order)
inline bool IsPathOrDexClassLoader(ScopedObjectAccessAlreadyRunnable& soa,
Handle<mirror::ClassLoader> class_loader)
REQUIRES_SHARED(Locks::mutator_lock_) {
@@ -41,6 +41,15 @@
soa.Decode<mirror::Class>(WellKnownClasses::dalvik_system_DexClassLoader));
}
+// Returns true if the given class loader is an InMemoryDexClassLoader.
+inline bool IsInMemoryDexClassLoader(ScopedObjectAccessAlreadyRunnable& soa,
+ Handle<mirror::ClassLoader> class_loader)
+ REQUIRES_SHARED(Locks::mutator_lock_) {
+ mirror::Class* class_loader_class = class_loader->GetClass();
+ return (class_loader_class ==
+ soa.Decode<mirror::Class>(WellKnownClasses::dalvik_system_InMemoryDexClassLoader));
+}
+
inline bool IsDelegateLastClassLoader(ScopedObjectAccessAlreadyRunnable& soa,
Handle<mirror::ClassLoader> class_loader)
REQUIRES_SHARED(Locks::mutator_lock_) {