From 93d99f3665cbd890509f4c707e1a62c5f26d320e Mon Sep 17 00:00:00 2001 From: Nicolas Geoffray Date: Wed, 27 Mar 2019 08:56:02 +0000 Subject: Revert "InMemoryDexClassLoader in ClassLoaderContext follow-up" This reverts commit 1a1398ec15accbd905d802e1391c8efbd2d80f98. Bug: 72131483 Reason for revert: Broke class_loader_context_test on target Change-Id: Iaa51c8e84536638f39e9ca4c420d1e10ae15e270 --- runtime/class_loader_context_test.cc | 37 ++++++++++++++---------------------- 1 file changed, 14 insertions(+), 23 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 531a69031d..7fba830787 100644 --- a/runtime/class_loader_context_test.cc +++ b/runtime/class_loader_context_test.cc @@ -283,22 +283,10 @@ TEST_F(ClassLoaderContextTest, ParseValidContextDLC) { VerifyClassLoaderDLC(context.get(), 0, "a.dex"); } -TEST_F(ClassLoaderContextTest, ParseValidContextIMC) { - std::unique_ptr context = ParseContextWithChecksums("IMC[*111]"); - ASSERT_FALSE(context == nullptr); -} - -TEST_F(ClassLoaderContextTest, ParseInvalidContextIMCNoChecksum) { +TEST_F(ClassLoaderContextTest, ParseInvalidContextIMC) { // IMC is treated as an unknown class loader unless a checksum is provided. // This is because the dex location is always bogus. - std::unique_ptr context = ClassLoaderContext::Create("IMC[]"); - ASSERT_TRUE(context == nullptr); -} - -TEST_F(ClassLoaderContextTest, ParseInvalidContextIMCWrongClasspathMagic) { - // IMC does not support arbitrary dex location. A magic marker must be used - // otherwise the spec should be rejected. - std::unique_ptr context = ClassLoaderContext::Create("IMC[a.dex*111]"); + std::unique_ptr context = ClassLoaderContext::Create("IMC[a.dex]"); ASSERT_TRUE(context == nullptr); } @@ -512,7 +500,11 @@ TEST_F(ClassLoaderContextTest, OpenDexFilesForIMCFails) { std::unique_ptr context; std::string dex_name = GetTestDexFileName("Main"); - context = ParseContextWithChecksums("IMC[*111]"); + context = ParseContextWithChecksums("PCL[" + dex_name + "*111]"); + VerifyContextSize(context.get(), 1); + ASSERT_TRUE(context->OpenDexFiles(InstructionSet::kArm, ".")); + + context = ParseContextWithChecksums("IMC[" + dex_name + "*111]"); VerifyContextSize(context.get(), 1); ASSERT_FALSE(context->OpenDexFiles(InstructionSet::kArm, ".")); } @@ -1210,7 +1202,7 @@ TEST_F(ClassLoaderContextTest, VerifyClassLoaderContextMatch) { } TEST_F(ClassLoaderContextTest, VerifyClassLoaderContextWithIMCMatch) { - std::string context_spec = "PCL[a.dex*123:b.dex*456];DLC[c.dex*890];IMC[*111]"; + std::string context_spec = "PCL[a.dex*123:b.dex*456];DLC[c.dex*890];IMC[d.dex*111]"; 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). @@ -1219,7 +1211,7 @@ TEST_F(ClassLoaderContextTest, VerifyClassLoaderContextWithIMCMatch) { VerifyContextSize(context.get(), 3); VerifyClassLoaderPCL(context.get(), 0, "a.dex:b.dex"); VerifyClassLoaderDLC(context.get(), 1, "c.dex"); - VerifyClassLoaderIMC(context.get(), 2, ""); + VerifyClassLoaderIMC(context.get(), 2, "d.dex"); ASSERT_EQ(context->VerifyClassLoaderContextMatch(context_spec), ClassLoaderContext::VerificationResult::kVerifies); @@ -1294,19 +1286,18 @@ TEST_F(ClassLoaderContextTest, VerifyClassLoaderContextMatchWithSL) { TEST_F(ClassLoaderContextTest, VerifyClassLoaderContextMatchWithIMCSL) { std::string context_spec = - "IMC[*123:*456]" - "{IMC[*321];IMC[*654]#IMC[*098:*999]};" - "DLC[c.dex*890]"; + "IMC[a.dex*123:b.dex*456]{IMC[d.dex*321];IMC[e.dex*654]#IMC[f.dex*098:g.dex*999]}" + ";DLC[c.dex*890]"; 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()); VerifyContextSize(context.get(), 2); - VerifyClassLoaderIMC(context.get(), 0, ":"); + VerifyClassLoaderIMC(context.get(), 0, "a.dex:b.dex"); VerifyClassLoaderDLC(context.get(), 1, "c.dex"); - VerifyClassLoaderSharedLibraryIMC(context.get(), 0, 0, ""); - VerifyClassLoaderSharedLibraryIMC(context.get(), 0, 1, ":"); + VerifyClassLoaderSharedLibraryIMC(context.get(), 0, 0, "d.dex"); + VerifyClassLoaderSharedLibraryIMC(context.get(), 0, 1, "f.dex:g.dex"); ASSERT_EQ(context->VerifyClassLoaderContextMatch(context_spec), ClassLoaderContext::VerificationResult::kVerifies); -- cgit v1.2.3-59-g8ed1b