From 81c6f8db12b203878a7d72444ead2bc7cf5c47ad Mon Sep 17 00:00:00 2001 From: Andreas Gampe Date: Wed, 25 Mar 2015 17:19:53 -0700 Subject: ART: PathClassLoader for compiler Use an actual PathClassLoader when compiling apps, instead of a side structure and cutout. This CL sets up a minimal object 'cluster' that recreates the Java side of a regular ClassLoader such that the Class-Linker will recognize it and use the internal native fast-path. This CL removes the now unnecessary compile-time-classpath and replaces it with a single 'compiling-the-boot-image' flag in the compiler callbacks. Note: This functionality is *only* intended for the compiler, as the objects have not been completely initialized. Bug: 19781184 Change-Id: I7f36af12dd7852d21281110a25c119e8c0669c1d --- runtime/class_linker_test.cc | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'runtime/class_linker_test.cc') diff --git a/runtime/class_linker_test.cc b/runtime/class_linker_test.cc index 1789ab12d2..a895a494a1 100644 --- a/runtime/class_linker_test.cc +++ b/runtime/class_linker_test.cc @@ -621,6 +621,20 @@ TEST_F(ClassLinkerTest, FindClassNonexistent) { AssertNonExistentClass("LNoSuchClass;"); } +TEST_F(ClassLinkerTest, GetDexFiles) { + ScopedObjectAccess soa(Thread::Current()); + + jobject jclass_loader = LoadDex("Nested"); + std::vector dex_files(GetDexFiles(jclass_loader)); + ASSERT_EQ(dex_files.size(), 1U); + EXPECT_TRUE(EndsWith(dex_files[0]->GetLocation(), "Nested.jar")); + + jobject jclass_loader2 = LoadDex("MultiDex"); + std::vector dex_files2(GetDexFiles(jclass_loader2)); + ASSERT_EQ(dex_files2.size(), 2U); + EXPECT_TRUE(EndsWith(dex_files2[0]->GetLocation(), "MultiDex.jar")); +} + TEST_F(ClassLinkerTest, FindClassNested) { ScopedObjectAccess soa(Thread::Current()); StackHandleScope<1> hs(soa.Self()); @@ -985,11 +999,10 @@ TEST_F(ClassLinkerTest, ResolveVerifyAndClinit) { ScopedObjectAccess soa(Thread::Current()); jobject jclass_loader = LoadDex("StaticsFromCode"); + const DexFile* dex_file = GetFirstDexFile(jclass_loader); StackHandleScope<1> hs(soa.Self()); Handle class_loader( hs.NewHandle(soa.Decode(jclass_loader))); - const DexFile* dex_file = Runtime::Current()->GetCompileTimeClassPath(jclass_loader)[0]; - CHECK(dex_file != nullptr); mirror::Class* klass = class_linker_->FindClass(soa.Self(), "LStaticsFromCode;", class_loader); mirror::ArtMethod* clinit = klass->FindClassInitializer(); mirror::ArtMethod* getS0 = klass->FindDirectMethod("getS0", "()Ljava/lang/Object;"); -- cgit v1.2.3-59-g8ed1b