diff options
author | 2018-11-28 16:06:12 +0000 | |
---|---|---|
committer | 2018-11-29 17:16:04 +0000 | |
commit | a66d69e884b6f9f41a8da31e6d27b498984c7fa3 (patch) | |
tree | 58efae80d2b2161feff23143ab620242d1c09605 /runtime/class_loader_context_test.cc | |
parent | 8f50b2c27f9b32726bbadfcebba910640b94036e (diff) |
Support shared libraries in CreateContextFromClassLoader.
Missed this method in my previous set of shared libraries support.
bug: 120036590
bug: 120031686
Test: test.py, app startup with speed-profile
Change-Id: I5c1ec567cfa5452a1f510a3279a9e15125f429ba
Diffstat (limited to 'runtime/class_loader_context_test.cc')
-rw-r--r-- | runtime/class_loader_context_test.cc | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/runtime/class_loader_context_test.cc b/runtime/class_loader_context_test.cc index 0756982b65..3c5f1ef95d 100644 --- a/runtime/class_loader_context_test.cc +++ b/runtime/class_loader_context_test.cc @@ -23,6 +23,7 @@ #include "base/dchecked_vector.h" #include "base/stl_util.h" #include "class_linker.h" +#include "class_root.h" #include "common_runtime_test.h" #include "dex/dex_file.h" #include "handle_scope-inl.h" @@ -30,6 +31,7 @@ #include "mirror/class.h" #include "mirror/class_loader.h" #include "mirror/object-inl.h" +#include "mirror/object_array-alloc-inl.h" #include "oat_file_assistant.h" #include "runtime.h" #include "scoped_thread_state_change-inl.h" @@ -1230,4 +1232,30 @@ TEST_F(ClassLoaderContextTest, VerifyClassLoaderContextMatchAfterEncodingMultide ClassLoaderContext::VerificationResult::kVerifies); } +TEST_F(ClassLoaderContextTest, CreateContextForClassLoaderWithSharedLibraries) { + jobject class_loader_a = LoadDexInPathClassLoader("ForClassLoaderA", nullptr); + + ScopedObjectAccess soa(Thread::Current()); + StackHandleScope<1> hs(soa.Self()); + Handle<mirror::ObjectArray<mirror::ClassLoader>> libraries = hs.NewHandle( + mirror::ObjectArray<mirror::ClassLoader>::Alloc( + soa.Self(), + GetClassRoot<mirror::ObjectArray<mirror::ClassLoader>>(), + 1)); + libraries->Set(0, soa.Decode<mirror::ClassLoader>(class_loader_a)); + + jobject class_loader_b = LoadDexInPathClassLoader( + "ForClassLoaderB", nullptr, soa.AddLocalReference<jobject>(libraries.Get())); + + std::unique_ptr<ClassLoaderContext> context = CreateContextForClassLoader(class_loader_b); + ASSERT_TRUE(context != nullptr); + std::vector<std::unique_ptr<const DexFile>> dex_files = OpenTestDexFiles("ForClassLoaderB"); + VerifyClassLoaderPCL(context.get(), 0, dex_files[0]->GetLocation()); + dex_files = OpenTestDexFiles("ForClassLoaderA"); + VerifyClassLoaderSharedLibraryPCL(context.get(), 0, 0, dex_files[0]->GetLocation()); + + ASSERT_EQ(context->VerifyClassLoaderContextMatch(context->EncodeContextForOatFile("")), + ClassLoaderContext::VerificationResult::kVerifies); +} + } // namespace art |