From a66d69e884b6f9f41a8da31e6d27b498984c7fa3 Mon Sep 17 00:00:00 2001 From: Nicolas Geoffray Date: Wed, 28 Nov 2018 16:06:12 +0000 Subject: 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 --- runtime/class_loader_context_test.cc | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'runtime/class_loader_context_test.cc') 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> libraries = hs.NewHandle( + mirror::ObjectArray::Alloc( + soa.Self(), + GetClassRoot>(), + 1)); + libraries->Set(0, soa.Decode(class_loader_a)); + + jobject class_loader_b = LoadDexInPathClassLoader( + "ForClassLoaderB", nullptr, soa.AddLocalReference(libraries.Get())); + + std::unique_ptr context = CreateContextForClassLoader(class_loader_b); + ASSERT_TRUE(context != nullptr); + std::vector> 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 -- cgit v1.2.3-59-g8ed1b