From 982ecedecd2326f9b28ee60a3feb56b299e1c2bc Mon Sep 17 00:00:00 2001 From: Nicolas Geoffray Date: Mon, 29 Mar 2021 08:49:38 +0100 Subject: Remove '&' class loader context. This is now an unsupported context. Test: class_loader_context Bug: 132357300 Change-Id: I21bc6e3529944a57379845e90c7f49759db30d40 --- runtime/class_loader_context_test.cc | 62 ++---------------------------------- 1 file changed, 3 insertions(+), 59 deletions(-) (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 ec51dee06c..bf51ae3a0f 100644 --- a/runtime/class_loader_context_test.cc +++ b/runtime/class_loader_context_test.cc @@ -208,7 +208,6 @@ class ClassLoaderContextTest : public CommonRuntimeTest { ASSERT_TRUE(context != nullptr); ASSERT_EQ(context->dex_files_state_, ClassLoaderContext::ContextDexFilesState::kDexFilesOpened); ASSERT_FALSE(context->owns_the_dex_files_); - ASSERT_FALSE(context->special_shared_library_); } void VerifyClassLoaderDexFiles(ScopedObjectAccess& soa, @@ -390,10 +389,10 @@ TEST_F(ClassLoaderContextTest, ParseValidEmptyContext) { VerifyClassLoaderPCL(context.get(), 0, ""); } -TEST_F(ClassLoaderContextTest, ParseValidSharedLibraryContext) { +TEST_F(ClassLoaderContextTest, ParseInvalidSharedLibraryContext) { + // '&' used to be a special context. std::unique_ptr context = ClassLoaderContext::Create("&"); - // An shared library context should have no class loader in the chain. - VerifyContextSize(context.get(), 0); + ASSERT_TRUE(context == nullptr); } TEST_F(ClassLoaderContextTest, ParseValidContextPCL) { @@ -486,12 +485,6 @@ TEST_F(ClassLoaderContextTest, ParseValidEmptyContextSharedLibrary) { VerifySharedLibrariesSize(context.get(), 0, 0); } -TEST_F(ClassLoaderContextTest, ParseValidContextSpecialSymbol) { - std::unique_ptr context = - ClassLoaderContext::Create(OatFile::kSpecialSharedLibrary); - VerifyContextSize(context.get(), 0); -} - TEST_F(ClassLoaderContextTest, ParseInvalidValidContexts) { ASSERT_TRUE(nullptr == ClassLoaderContext::Create("ABC[a.dex]")); ASSERT_TRUE(nullptr == ClassLoaderContext::Create("PCL")); @@ -675,34 +668,6 @@ TEST_F(ClassLoaderContextTest, CreateClassLoaderWithEmptyContext) { soa.Decode(WellKnownClasses::java_lang_BootClassLoader)); } -TEST_F(ClassLoaderContextTest, CreateClassLoaderWithSharedLibraryContext) { - std::unique_ptr context = ClassLoaderContext::Create("&"); - - ASSERT_TRUE(context->OpenDexFiles()); - - std::vector> compilation_sources = OpenTestDexFiles("MultiDex"); - - std::vector compilation_sources_raw = - MakeNonOwningPointerVector(compilation_sources); - jobject jclass_loader = context->CreateClassLoader(compilation_sources_raw); - ASSERT_TRUE(jclass_loader != nullptr); - - ScopedObjectAccess soa(Thread::Current()); - - StackHandleScope<1> hs(soa.Self()); - Handle class_loader = hs.NewHandle( - soa.Decode(jclass_loader)); - - // A shared library context should create a single PathClassLoader with only the compilation - // sources. - VerifyClassLoaderDexFiles(soa, - class_loader, - WellKnownClasses::dalvik_system_PathClassLoader, - compilation_sources_raw); - ASSERT_TRUE(class_loader->GetParent()->GetClass() == - soa.Decode(WellKnownClasses::java_lang_BootClassLoader)); -} - TEST_F(ClassLoaderContextTest, CreateClassLoaderWithComplexChain) { // Setup the context. std::vector> classpath_dex_a = OpenTestDexFiles("ForClassLoaderA"); @@ -1470,16 +1435,6 @@ TEST_F(ClassLoaderContextTest, CreateContextForClassLoaderIMC) { VerifyClassLoaderPCLFromTestDex(context.get(), 3, "ForClassLoaderA"); } -TEST_F(ClassLoaderContextTest, VerifyClassLoaderContextFirstElement) { - std::string context_spec = "PCL[]"; - std::unique_ptr context = ParseContextWithChecksums(context_spec); - ASSERT_TRUE(context != nullptr); - PretendContextOpenedDexFilesForChecksums(context.get()); - // Ensure that the special shared library marks as verified for the first thing in the class path. - ASSERT_EQ(context->VerifyClassLoaderContextMatch(OatFile::kSpecialSharedLibrary), - ClassLoaderContext::VerificationResult::kVerifies); -} - TEST_F(ClassLoaderContextTest, VerifyClassLoaderContextMatch) { std::string context_spec = "PCL[a.dex*123:b.dex*456];DLC[c.dex*890]"; std::unique_ptr context = ParseContextWithChecksums(context_spec); @@ -1539,17 +1494,6 @@ TEST_F(ClassLoaderContextTest, VerifyClassLoaderContextWithIMCMatch) { ClassLoaderContext::VerificationResult::kVerifies); } -TEST_F(ClassLoaderContextTest, VerifyClassLoaderContextMatchSpecial) { - std::string context_spec = "&"; - std::unique_ptr context = ParseContextWithChecksums(context_spec); - // Pretend that we successfully open the dex files to pass the DCHECKS. - // (as it's much easier to test all the corner cases without relying on actual dex files). - PretendContextOpenedDexFiles(context.get()); - - ASSERT_EQ(context->VerifyClassLoaderContextMatch(context_spec), - ClassLoaderContext::VerificationResult::kForcedToSkipChecks); -} - TEST_F(ClassLoaderContextTest, VerifyClassLoaderContextMatchWithSL) { std::string context_spec = "PCL[a.dex*123:b.dex*456]{PCL[d.dex*321];PCL[e.dex*654]#PCL[f.dex*098:g.dex*999]}" -- cgit v1.2.3-59-g8ed1b