Allow dex2oat to create a full class loader context
We previously checked that dex2oat sees only a single class loader. This
CL removes the restriction and enables dex2oat to create and compile with
a full class loader context.
Test: m test-art-host
Bug: 38138251
Change-Id: I03e75a75757995ce8ce3addf0bc0a708e18ac050
diff --git a/runtime/common_runtime_test.h b/runtime/common_runtime_test.h
index 5893573..c494513 100644
--- a/runtime/common_runtime_test.h
+++ b/runtime/common_runtime_test.h
@@ -28,6 +28,7 @@
// TODO: Add inl file and avoid including inl.
#include "obj_ptr-inl.h"
#include "os.h"
+#include "scoped_thread_state_change-inl.h"
namespace art {
@@ -159,9 +160,12 @@
const DexFile* java_lang_dex_file_;
std::vector<const DexFile*> boot_class_path_;
- // Get the dex files from a PathClassLoader. This in order of the dex elements and their dex
- // arrays.
+ // Get the dex files from a PathClassLoader or DelegateLastClassLoader.
+ // This only looks into the current class loader and does not recurse into the parents.
std::vector<const DexFile*> GetDexFiles(jobject jclass_loader);
+ std::vector<const DexFile*> GetDexFiles(ScopedObjectAccess& soa,
+ Handle<mirror::ClassLoader> class_loader)
+ REQUIRES_SHARED(Locks::mutator_lock_);
// Get the first dex file from a PathClassLoader. Will abort if it is null.
const DexFile* GetFirstDexFile(jobject jclass_loader);
@@ -176,6 +180,15 @@
// initializers, initialize well-known classes, and creates the heap thread pool.
virtual void FinalizeSetup();
+ // Creates the class path string for the given dex files (the list of dex file locations
+ // separated by ':').
+ std::string CreateClassPath(
+ const std::vector<std::unique_ptr<const DexFile>>& dex_files);
+ // Same as CreateClassPath but add the dex file checksum after each location. The separator
+ // is '*'.
+ std::string CreateClassPathWithChecksums(
+ const std::vector<std::unique_ptr<const DexFile>>& dex_files);
+
private:
static std::string GetCoreFileLocation(const char* suffix);