From 966878d987cec1940fdfa8633fc79f8112320821 Mon Sep 17 00:00:00 2001 From: Mathieu Chartier Date: Thu, 14 Jan 2016 14:33:29 -0800 Subject: [PATCH] Revert "Create parent class loader for dex2oat" Bug: 22858531 This reverts commit d37d364c27e74a7b49970a8c970482e273aa7b1a. Change-Id: Id71a6f3bb9a29c04a5c13210633674e05d798114 --- dex2oat/dex2oat.cc | 9 +++------ oatdump/oatdump.cc | 2 +- runtime/class_linker.cc | 15 ++++++--------- runtime/class_linker.h | 5 +---- runtime/common_runtime_test.cc | 3 +-- 5 files changed, 12 insertions(+), 22 deletions(-) diff --git a/dex2oat/dex2oat.cc b/dex2oat/dex2oat.cc index 808643a6a..dcfd5c7cb 100644 --- a/dex2oat/dex2oat.cc +++ b/dex2oat/dex2oat.cc @@ -1369,7 +1369,6 @@ class Dex2Oat FINAL { // Handle and ClassLoader creation needs to come after Runtime::Create jobject class_loader = nullptr; - jobject class_path_class_loader = nullptr; Thread* self = Thread::Current(); if (!boot_image_filename_.empty()) { @@ -1384,12 +1383,10 @@ class Dex2Oat FINAL { key_value_store_->Put(OatHeader::kClassPathKey, OatFile::EncodeDexFileDependencies(class_path_files)); - class_path_class_loader = class_linker->CreatePathClassLoader(self, - class_path_files, - nullptr); + // Then the dex files we'll compile. Thus we'll resolve the class-path first. + class_path_files.insert(class_path_files.end(), dex_files_.begin(), dex_files_.end()); - // Class path loader as parent so that we'll resolve there first. - class_loader = class_linker->CreatePathClassLoader(self, dex_files_, class_path_class_loader); + class_loader = class_linker->CreatePathClassLoader(self, class_path_files); } // Find the dex file we should not inline from. diff --git a/oatdump/oatdump.cc b/oatdump/oatdump.cc index 52c65247c..69e767dbd 100644 --- a/oatdump/oatdump.cc +++ b/oatdump/oatdump.cc @@ -2424,7 +2424,7 @@ static int DumpOatWithRuntime(Runtime* runtime, OatFile* oat_file, OatDumperOpti // Need a class loader. // Fake that we're a compiler. - jobject class_loader = class_linker->CreatePathClassLoader(self, class_path, /*parent*/nullptr); + jobject class_loader = class_linker->CreatePathClassLoader(self, class_path); // Use the class loader while dumping. StackHandleScope<1> scope(self); diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc index 3d0629554..ddd285a4d 100644 --- a/runtime/class_linker.cc +++ b/runtime/class_linker.cc @@ -6901,9 +6901,7 @@ bool ClassLinker::MayBeCalledWithDirectCodePointer(ArtMethod* m) { } } -jobject ClassLinker::CreatePathClassLoader(Thread* self, - std::vector& dex_files, - jobject parent_loader) { +jobject ClassLinker::CreatePathClassLoader(Thread* self, std::vector& dex_files) { // SOAAlreadyRunnable is protected, and we need something to add a global reference. // We could move the jobject to the callers, but all call-sites do this... ScopedObjectAccessUnchecked soa(self); @@ -6934,8 +6932,8 @@ jobject ClassLinker::CreatePathClassLoader(Thread* self, for (const DexFile* dex_file : dex_files) { StackHandleScope<3> hs2(self); - // CreatePathClassLoader is only used by gtests and dex2oat. Index 0 of h_long_array is - // supposed to be the oat file but we can leave it null. + // CreatePathClassLoader is only used by gtests. Index 0 of h_long_array is supposed to be the + // oat file but we can leave it null. Handle h_long_array = hs2.NewHandle(mirror::LongArray::Alloc( self, kDexFileIndexStart + 1)); @@ -6981,10 +6979,9 @@ jobject ClassLinker::CreatePathClassLoader(Thread* self, mirror::Class::FindField(self, hs.NewHandle(h_path_class_loader->GetClass()), "parent", "Ljava/lang/ClassLoader;"); DCHECK(parent_field != nullptr); - mirror::Object* parent = (parent_loader != nullptr) - ? soa.Decode(parent_loader) - : soa.Decode(WellKnownClasses::java_lang_BootClassLoader)->AllocObject(self); - parent_field->SetObject(h_path_class_loader.Get(), parent); + mirror::Object* boot_cl = + soa.Decode(WellKnownClasses::java_lang_BootClassLoader)->AllocObject(self); + parent_field->SetObject(h_path_class_loader.Get(), boot_cl); // Make it a global ref and return. ScopedLocalRef local_ref( diff --git a/runtime/class_linker.h b/runtime/class_linker.h index 9d432c660..f1fd0c38f 100644 --- a/runtime/class_linker.h +++ b/runtime/class_linker.h @@ -523,10 +523,7 @@ class ClassLinker { // Creates a GlobalRef PathClassLoader that can be used to load classes from the given dex files. // Note: the objects are not completely set up. Do not use this outside of tests and the compiler. - // If parent_loader is null then we use the boot class loader. - jobject CreatePathClassLoader(Thread* self, - std::vector& dex_files, - jobject parent_loader) + jobject CreatePathClassLoader(Thread* self, std::vector& dex_files) SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!dex_lock_); diff --git a/runtime/common_runtime_test.cc b/runtime/common_runtime_test.cc index a4e16ae71..2184f0aee 100644 --- a/runtime/common_runtime_test.cc +++ b/runtime/common_runtime_test.cc @@ -591,8 +591,7 @@ jobject CommonRuntimeTest::LoadDex(const char* dex_name) { Thread* self = Thread::Current(); jobject class_loader = Runtime::Current()->GetClassLinker()->CreatePathClassLoader(self, - class_path, - nullptr); + class_path); self->SetClassLoaderOverride(class_loader); return class_loader; } -- 2.11.0