From 05909d81d322c0b20445e672c338c626e43f650d Mon Sep 17 00:00:00 2001 From: David Brazdil Date: Thu, 6 Dec 2018 16:25:16 +0000 Subject: 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 --- runtime/class_loader_utils.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'runtime/class_loader_utils.h') diff --git a/runtime/class_loader_utils.h b/runtime/class_loader_utils.h index 945d659396..ab28cf8c7d 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 class_loader) REQUIRES_SHARED(Locks::mutator_lock_) { @@ -41,6 +41,15 @@ inline bool IsPathOrDexClassLoader(ScopedObjectAccessAlreadyRunnable& soa, soa.Decode(WellKnownClasses::dalvik_system_DexClassLoader)); } +// Returns true if the given class loader is an InMemoryDexClassLoader. +inline bool IsInMemoryDexClassLoader(ScopedObjectAccessAlreadyRunnable& soa, + Handle class_loader) + REQUIRES_SHARED(Locks::mutator_lock_) { + mirror::Class* class_loader_class = class_loader->GetClass(); + return (class_loader_class == + soa.Decode(WellKnownClasses::dalvik_system_InMemoryDexClassLoader)); +} + inline bool IsDelegateLastClassLoader(ScopedObjectAccessAlreadyRunnable& soa, Handle class_loader) REQUIRES_SHARED(Locks::mutator_lock_) { -- cgit v1.2.3-59-g8ed1b