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/dex2oat/dex2oat_test.cc b/dex2oat/dex2oat_test.cc
index b08b055..3538215 100644
--- a/dex2oat/dex2oat_test.cc
+++ b/dex2oat/dex2oat_test.cc
@@ -1023,4 +1023,16 @@
   RunTest(context.c_str(), kEmptyClassPathKey, /*expected_success*/ true);
 }
 
+TEST_F(Dex2oatClassLoaderContextTest, ChainContext) {
+  std::vector<std::unique_ptr<const DexFile>> dex_files1 = OpenTestDexFiles("Nested");
+  std::vector<std::unique_ptr<const DexFile>> dex_files2 = OpenTestDexFiles("MultiDex");
+
+  std::string context = "PCL[" + GetTestDexFileName("Nested") + "];" +
+      "DLC[" + GetTestDexFileName("MultiDex") + "]";
+  std::string expected_classpath_key = "PCL[" + CreateClassPathWithChecksums(dex_files1) + "];" +
+      "DLC[" + CreateClassPathWithChecksums(dex_files2) + "]";
+
+  RunTest(context.c_str(), expected_classpath_key.c_str(), true);
+}
+
 }  // namespace art