Include core library jars in runtime apex.

Bug: 110870380
Test: m && no core library jars on /system && boots && CtsJdwpTestCases
Change-Id: If561cdc80661eaf2aa55ee012ab42bfad580bf88
diff --git a/build/apex/Android.bp b/build/apex/Android.bp
index aa199d3..9bf6551 100644
--- a/build/apex/Android.bp
+++ b/build/apex/Android.bp
@@ -85,6 +85,15 @@
     "libopenjdk",
 ]
 
+// Java libraries
+libcore_target_java_libs = [
+    "core-oj",
+    "core-libart",
+    "okhttp",
+    "bouncycastle",
+    "apache-xml",
+]
+
 apex_key {
     name: "com.android.runtime.key",
     public_key: "com.android.runtime.avbpubkey",
@@ -108,6 +117,7 @@
     name: "com.android.runtime.release",
     compile_multilib: "both",
     manifest: "manifest.json",
+    java_libs: libcore_target_java_libs,
     native_shared_libs: art_runtime_base_native_shared_libs
         + bionic_native_shared_libs
         + libcore_native_shared_libs,
@@ -137,6 +147,7 @@
     name: "com.android.runtime.debug",
     compile_multilib: "both",
     manifest: "manifest.json",
+    java_libs: libcore_target_java_libs,
     native_shared_libs: art_runtime_base_native_shared_libs
         + art_runtime_debug_native_shared_libs
         + bionic_native_shared_libs
diff --git a/build/apex/runtests.sh b/build/apex/runtests.sh
index 4c0e772..83c42bc 100755
--- a/build/apex/runtests.sh
+++ b/build/apex/runtests.sh
@@ -144,6 +144,10 @@
     || fail_check "Cannot find library '$1' in mounted image"
 }
 
+function check_java_library {
+  [[ -x "$mount_point/javalib/$1" ]] || fail_check "Cannot find java library '$1' in mounted image"
+}
+
 # Check contents of APEX payload located in `$mount_point`.
 function check_release_contents {
   # Check that the mounted image contains an APEX manifest.
@@ -189,6 +193,15 @@
   #   ...
   #
   # ?
+
+  # TODO: Enable for host
+  if [ $1 != "com.android.runtime.host" ]; then
+    check_java_library core-oj.jar
+    check_java_library core-libart.jar
+    check_java_library okhttp.jar
+    check_java_library bouncycastle.jar
+    check_java_library apache-xml.jar
+  fi
 }
 
 # Check debug contents of APEX payload located in `$mount_point`.
@@ -286,7 +299,7 @@
 
 # Run tests on APEX package.
 say "Checking APEX package $apex_module"
-check_release_contents
+check_release_contents "$apex_module"
 
 # Clean up.
 trap - EXIT
@@ -319,7 +332,7 @@
 
 # Run tests on APEX package.
 say "Checking APEX package $apex_module"
-check_release_contents
+check_release_contents "$apex_module"
 check_debug_contents
 # Check for files pulled in from debug target-only oatdump.
 check_binary oatdump
@@ -390,7 +403,7 @@
 
 # Run tests on APEX package.
 say "Checking APEX package $apex_module"
-check_release_contents
+check_release_contents "$apex_module"
 check_debug_contents
 
 # Clean up.