Clean up ART APEX manifests. am: 5fef55677e am: bdede126c6

Original change: https://android-review.googlesource.com/c/platform/art/+/1742176

Change-Id: Ib93ff30fd91d8af9bfa7db5671d804a4e7282db1
diff --git a/build/apex/manifest-art.json b/build/apex/manifest-art.json
index 4bbd03e..43a49c8 100644
--- a/build/apex/manifest-art.json
+++ b/build/apex/manifest-art.json
@@ -5,10 +5,6 @@
     "libjdwp.so"
   ],
   "requireNativeLibs": [
-    "libicu.so",
-    "libicuuc.so",
-    "libicui18n.so",
-    "libicu_jni.so",
-    "libneuralnetworks.so"
+    "libicu_jni.so"
   ]
 }
diff --git a/build/apex/test_apex_manifest.json b/build/apex/test_apex_manifest.json
index a264d7a..ee6dacb 100644
--- a/build/apex/test_apex_manifest.json
+++ b/build/apex/test_apex_manifest.json
@@ -2,29 +2,9 @@
   "name": "com.android.art",
   "version": 2147483647,
   "provideNativeLibs": [
-    "libandroidio.so",
-    "libdexfile_external.so",
-    "libdexfiled_external.so",
-    "libjdwp.so",
-    "libnativebridge.so",
-    "libnativehelper.so",
-    "libnativeloader.so",
-    "libsigchain.so"
+    "libjdwp.so"
   ],
   "requireNativeLibs": [
-    "heapprofd_client_api.so",
-    "libadbconnection_client.so",
-    "libc.so",
-    "libdl.so",
-    "libdl_android.so",
-    "libicu.so",
-    "libicuuc.so",
-    "libicui18n.so",
-    "libicu_jni.so",
-    "liblog.so",
-    "libm.so",
-    "libneuralnetworks.so",
-    "libstatssocket.so",
-    "libz.so"
+    "libicu_jni.so"
   ]
 }
diff --git a/runtime/Android.bp b/runtime/Android.bp
index 74c8460..571d7fe 100644
--- a/runtime/Android.bp
+++ b/runtime/Android.bp
@@ -367,6 +367,7 @@
             },
         },
     },
+
     target: {
         android: {
             srcs: [
@@ -419,6 +420,7 @@
             ],
         },
     },
+
     generated_sources: [
         "art_operator_srcs",
     ],
@@ -426,6 +428,7 @@
     generated_headers: ["cpp-define-generator-asm-support"],
     // export our headers so the libart-gtest targets can use it as well.
     export_generated_headers: ["cpp-define-generator-asm-support"],
+
     header_libs: [
         "art_cmdlineparser_headers",
         "cpp-define-generator-definitions",
@@ -448,6 +451,20 @@
         "libunwindstack",
     ],
     static_libs: ["libodrstatslog"],
+
+    runtime_libs: [
+        // Libraries loaded at runtime. Exceptions:
+        // - libart(d)-compiler.so and libopenjdk(d).so cannot be listed here
+        //   due to cyclic dependency.
+        // - libicu_jni.so is only loaded to handle dependency order in VM
+        //   startup (see Runtime::InitNativeMethods), but its API is internal
+        //   to com.android.i18n and not used by ART/libcore. Therefore it's not
+        //   listed here to avoid visibility issues. Instead it's linked from
+        //   the ART module namespace through an entry in requireNativeLibs in
+        //   manifest-art.json.
+        "libjavacore",
+    ],
+
     export_include_dirs: ["."],
     // ART's macros.h depends on libbase's macros.h.
     // Note: runtime_options.h depends on cmdline. But we don't really want to export this
diff --git a/runtime/runtime.cc b/runtime/runtime.cc
index 264a19a..dc4acc0 100644
--- a/runtime/runtime.cc
+++ b/runtime/runtime.cc
@@ -2046,6 +2046,10 @@
   // a regular JNI libraries with a regular JNI_OnLoad. Most JNI libraries can
   // just use System.loadLibrary, but libcore can't because it's the library
   // that implements System.loadLibrary!
+  //
+  // By setting calling class to java.lang.Object, the caller location for these
+  // JNI libs is core-oj.jar in the ART APEX, and hence they are loaded from the
+  // com_android_art linker namespace.
 
   // libicu_jni has to be initialized before libopenjdk{d} due to runtime dependency from
   // libopenjdk{d} to Icu4cMetadata native methods in libicu_jni. See http://b/143888405