Merge "Revert "Build dex2oatd with compile_multilib: both.""
diff --git a/build/Android.common_path.mk b/build/Android.common_path.mk
index 5208d64..c321733 100644
--- a/build/Android.common_path.mk
+++ b/build/Android.common_path.mk
@@ -74,7 +74,7 @@
 TARGET_CORE_IMG_LOCATION := $(ART_TARGET_TEST_OUT)/core.art
 
 # Modules to compile for core.art.
-CORE_IMG_JARS := core-oj core-libart core-simple okhttp bouncycastle apache-xml
+CORE_IMG_JARS := core-oj core-libart okhttp bouncycastle apache-xml
 HOST_CORE_IMG_JARS   := $(addsuffix -hostdex,$(CORE_IMG_JARS))
 TARGET_CORE_IMG_JARS := $(addsuffix -testdex,$(CORE_IMG_JARS))
 HOST_CORE_IMG_DEX_LOCATIONS   := $(foreach jar,$(HOST_CORE_IMG_JARS),  $(HOST_OUT_JAVA_LIBRARIES)/$(jar).jar)
diff --git a/build/apex/Android.bp b/build/apex/Android.bp
index 47729c1..aa199d3 100644
--- a/build/apex/Android.bp
+++ b/build/apex/Android.bp
@@ -34,14 +34,17 @@
     "dexoptanalyzerd",
     "profmand",
 ]
+// - Debug variants (libraries).
 art_runtime_debug_native_shared_libs = [
     "libartd",
     "libartd-compiler",
-    "libopenjdkd",
     "libopenjdkjvmd",
     "libopenjdkjvmtid",
     "libadbconnectiond",
 ]
+libcore_debug_native_shared_libs = [
+    "libopenjdkd",
+]
 
 // Data files associated with bionic / managed core library APIs.
 art_runtime_data_file_prebuilts = [
@@ -77,6 +80,11 @@
 art_tools_device_binaries = art_tools_common_binaries + art_tools_device_only_binaries
 art_tools_host_binaries = art_tools_common_binaries + art_tools_host_only_binaries
 
+// (Some) Libcore native libraries.
+libcore_native_shared_libs = [
+    "libopenjdk",
+]
+
 apex_key {
     name: "com.android.runtime.key",
     public_key: "com.android.runtime.avbpubkey",
@@ -101,7 +109,8 @@
     compile_multilib: "both",
     manifest: "manifest.json",
     native_shared_libs: art_runtime_base_native_shared_libs
-        + bionic_native_shared_libs,
+        + bionic_native_shared_libs
+        + libcore_native_shared_libs,
     multilib: {
         both: {
             // TODO: Add logic to create a `dalvikvm` symlink to `dalvikvm32` or `dalvikvm64`
@@ -130,7 +139,9 @@
     manifest: "manifest.json",
     native_shared_libs: art_runtime_base_native_shared_libs
         + art_runtime_debug_native_shared_libs
-        + bionic_native_shared_libs,
+        + bionic_native_shared_libs
+        + libcore_native_shared_libs
+        + libcore_debug_native_shared_libs,
     multilib: {
         both: {
             // TODO: Add logic to create a `dalvikvm` symlink to `dalvikvm32` or `dalvikvm64`
@@ -164,7 +175,9 @@
     device_supported: false,
     manifest: "manifest.json",
     native_shared_libs: art_runtime_base_native_shared_libs
-        + art_runtime_debug_native_shared_libs,
+        + art_runtime_debug_native_shared_libs
+        + libcore_native_shared_libs
+        + libcore_debug_native_shared_libs,
     multilib: {
         both: {
             // TODO: Add logic to create a `dalvikvm` symlink to `dalvikvm32` or `dalvikvm64`
diff --git a/build/apex/runtests.sh b/build/apex/runtests.sh
index 9db325a..b2aa4df 100755
--- a/build/apex/runtests.sh
+++ b/build/apex/runtests.sh
@@ -157,6 +157,7 @@
   check_library libprofile.so
   # Check that the mounted image contains Android Core libraries.
   check_library libjavacrypto.so
+  check_library libopenjdk.so
   # Check that the mounted image contains additional required libraries.
   check_library libadbconnection.so
 
@@ -193,11 +194,12 @@
   check_library libartd-dexlayout.so
   check_library libartd.so
   check_library libdexfiled.so
-  check_library libopenjdkd.so
   check_library libopenjdkjvmd.so
   check_library libopenjdkjvmtid.so
   check_library libprofiled.so
-  # Check that the mounted image contains additional required libraries.
+  # Check that the mounted image contains Android Core debug libraries.
+  check_library libopenjdkd.so
+  # Check that the mounted image contains additional required debug libraries.
   check_library libadbconnectiond.so
 }
 
diff --git a/libartbase/base/common_art_test.cc b/libartbase/base/common_art_test.cc
index 53afea2..18e1bf0 100644
--- a/libartbase/base/common_art_test.cc
+++ b/libartbase/base/common_art_test.cc
@@ -335,7 +335,6 @@
       // CORE_IMG_JARS modules.
       "core-oj",
       "core-libart",
-      "core-simple",
       "okhttp",
       "bouncycastle",
       "apache-xml",
diff --git a/runtime/jni/java_vm_ext.cc b/runtime/jni/java_vm_ext.cc
index 7a9d292..6d4ceb5 100644
--- a/runtime/jni/java_vm_ext.cc
+++ b/runtime/jni/java_vm_ext.cc
@@ -87,9 +87,10 @@
       self->GetJniEnv()->DeleteWeakGlobalRef(class_loader_);
     }
 
-    std::string error_msg;
+    char* error_msg = nullptr;
     if (!android::CloseNativeLibrary(handle_, needs_native_bridge_, &error_msg)) {
       LOG(WARNING) << "Error while unloading native library \"" << path_ << "\": " << error_msg;
+      android::NativeLoaderFreeErrorMessage(error_msg);
     }
   }
 
@@ -962,17 +963,19 @@
   Locks::mutator_lock_->AssertNotHeld(self);
   const char* path_str = path.empty() ? nullptr : path.c_str();
   bool needs_native_bridge = false;
+  char* nativeloader_error_msg;
   void* handle = android::OpenNativeLibrary(env,
                                             runtime_->GetTargetSdkVersion(),
                                             path_str,
                                             class_loader,
                                             library_path.get(),
                                             &needs_native_bridge,
-                                            error_msg);
-
+                                            &nativeloader_error_msg);
   VLOG(jni) << "[Call to dlopen(\"" << path << "\", RTLD_NOW) returned " << handle << "]";
 
   if (handle == nullptr) {
+    *error_msg = nativeloader_error_msg;
+    free(nativeloader_error_msg);
     VLOG(jni) << "dlopen(\"" << path << "\", RTLD_NOW) failed: " << *error_msg;
     return false;
   }
diff --git a/runtime/ti/agent.cc b/runtime/ti/agent.cc
index 033c8ac..0202fbc 100644
--- a/runtime/ti/agent.cc
+++ b/runtime/ti/agent.cc
@@ -118,7 +118,7 @@
                                            : JavaVMExt::GetLibrarySearchPath(env, class_loader));
 
   bool needs_native_bridge = false;
-  std::string nativeloader_error_msg;
+  char* nativeloader_error_msg = nullptr;
   void* dlopen_handle = android::OpenNativeLibrary(env,
                                                    Runtime::Current()->GetTargetSdkVersion(),
                                                    name_.c_str(),
@@ -129,7 +129,8 @@
   if (dlopen_handle == nullptr) {
     *error_msg = StringPrintf("Unable to dlopen %s: %s",
                               name_.c_str(),
-                              nativeloader_error_msg.c_str());
+                              nativeloader_error_msg);
+    android::NativeLoaderFreeErrorMessage(nativeloader_error_msg);
     *error = kLoadingError;
     return nullptr;
   }
@@ -137,7 +138,7 @@
     // TODO: Consider support?
     // The result of this call and error_msg is ignored because the most
     // relevant error is that native bridge is unsupported.
-    android::CloseNativeLibrary(dlopen_handle, needs_native_bridge, error_msg);
+    android::CloseNativeLibrary(dlopen_handle, needs_native_bridge, &nativeloader_error_msg);
     *error_msg = StringPrintf("Native-bridge agents unsupported: %s", name_.c_str());
     *error = kLoadingError;
     return nullptr;
diff --git a/sigchainlib/Android.bp b/sigchainlib/Android.bp
index 1d5ec2b..5f055ec 100644
--- a/sigchainlib/Android.bp
+++ b/sigchainlib/Android.bp
@@ -37,12 +37,6 @@
             whole_static_libs: ["libasync_safe"],
         },
     },
-    // Sigchainlib is whole-statically linked into binaries. For Android.mk-based binaries,
-    // this will drag ASAN symbols into the binary, even for modules using LOCAL_SANITIZE := never.
-    // So disable sanitization for now. b/38456126
-    sanitize: {
-        never: true,
-    },
 }
 
 // Create a dummy version of libsigchain which expose the necessary symbols
diff --git a/test/etc/run-test-jar b/test/etc/run-test-jar
index 3074763..b35a43a 100755
--- a/test/etc/run-test-jar
+++ b/test/etc/run-test-jar
@@ -556,7 +556,7 @@
 # Note: This must start with the CORE_IMG_JARS in Android.common_path.mk
 # because that's what we use for compiling the core.art image.
 # It may contain additional modules from TEST_CORE_JARS.
-bpath_modules="core-oj core-libart core-simple okhttp bouncycastle apache-xml conscrypt"
+bpath_modules="core-oj core-libart okhttp bouncycastle apache-xml conscrypt"
 if [ "${HOST}" = "y" ]; then
     framework="${ANDROID_HOST_OUT}/framework"
     if [ "${ANDROID_HOST_OUT:0:${#ANDROID_BUILD_TOP}+1}" = "${ANDROID_BUILD_TOP}/" ]; then
diff --git a/tools/art b/tools/art
index 2c28807..58a8150 100644
--- a/tools/art
+++ b/tools/art
@@ -495,7 +495,7 @@
   # Note: This must start with the CORE_IMG_JARS in Android.common_path.mk
   # because that's what we use for compiling the core.art image.
   # It may contain additional modules from TEST_CORE_JARS.
-  core_jars_list="core-oj core-libart core-simple okhttp bouncycastle apache-xml conscrypt"
+  core_jars_list="core-oj core-libart okhttp bouncycastle apache-xml conscrypt"
   core_jars_suffix=
   if [[ -e $ANDROID_ROOT/framework/core-oj-hostdex.jar ]]; then
     core_jars_suffix=-hostdex
diff --git a/tools/bootjars.sh b/tools/bootjars.sh
index 320d4b5..78df99c 100755
--- a/tools/bootjars.sh
+++ b/tools/bootjars.sh
@@ -75,7 +75,7 @@
   # Note: This must start with the CORE_IMG_JARS in Android.common_path.mk
   # because that's what we use for compiling the core.art image.
   # It may contain additional modules from TEST_CORE_JARS.
-  core_jars_list="core-oj core-libart core-simple okhttp bouncycastle apache-xml conscrypt"
+  core_jars_list="core-oj core-libart okhttp bouncycastle apache-xml conscrypt"
   core_jars_suffix=
   if [[ $mode == target ]]; then
     core_jars_suffix=-testdex
diff --git a/tools/libcore_failures.txt b/tools/libcore_failures.txt
index 7ef20bd..9b0873e 100644
--- a/tools/libcore_failures.txt
+++ b/tools/libcore_failures.txt
@@ -230,7 +230,6 @@
   modes: [device_testdex],
   bug: 122642227,
   names: [
-    "libcore.java.lang.SystemTest#testSystemProperties_mutable",
     "libcore.libcore.icu.TimeZoneIntegrationTest#testTimeZoneDataVersion",
     "libcore.libcore.icu.TimeZoneIntegrationTest#testTimeZoneDebugInfo",
     "libcore.libcore.icu.TimeZoneIntegrationTest#testTzDataSetVersions"
diff --git a/tools/run-jdwp-tests.sh b/tools/run-jdwp-tests.sh
index ac9f09a..fbd8077 100755
--- a/tools/run-jdwp-tests.sh
+++ b/tools/run-jdwp-tests.sh
@@ -58,7 +58,7 @@
 # Note: This must start with the CORE_IMG_JARS in Android.common_path.mk
 # because that's what we use for compiling the core.art image.
 # It may contain additional modules from TEST_CORE_JARS.
-BOOT_CLASSPATH_JARS="core-oj core-libart core-simple okhttp bouncycastle apache-xml conscrypt"
+BOOT_CLASSPATH_JARS="core-oj core-libart okhttp bouncycastle apache-xml conscrypt"
 
 vm_args=""
 art="$android_root/bin/art"
diff --git a/tools/run-libcore-tests.sh b/tools/run-libcore-tests.sh
index ea7464f..735549e 100755
--- a/tools/run-libcore-tests.sh
+++ b/tools/run-libcore-tests.sh
@@ -60,7 +60,7 @@
 # Note: This must start with the CORE_IMG_JARS in Android.common_path.mk
 # because that's what we use for compiling the core.art image.
 # It may contain additional modules from TEST_CORE_JARS.
-BOOT_CLASSPATH_JARS="core-oj core-libart core-simple okhttp bouncycastle apache-xml conscrypt"
+BOOT_CLASSPATH_JARS="core-oj core-libart okhttp bouncycastle apache-xml conscrypt"
 
 DEPS="core-tests jsr166-tests mockito-target"