From 65ff8ee1344d5bd2a9f068348992c3b9c8496d31 Mon Sep 17 00:00:00 2001 From: Andreas Gampe Date: Fri, 14 Nov 2014 16:15:17 -0800 Subject: [PATCH] Frameworks/base: AndroidRuntime standalone preloaded-classes Change AndroidRuntime::startVM to give the new standalone preloaded-classes file to the runtime for compilation of images. Bug: 18305157 (cherry picked from commit 995c62d6abd4b7080e52a60d1bffa32ae4a798a3) Change-Id: I32a13357893222b25fbce60bf2367c23fb36ab22 --- core/jni/AndroidRuntime.cpp | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/core/jni/AndroidRuntime.cpp b/core/jni/AndroidRuntime.cpp index 23b4dad3a2cf0..21d4fbd1ae2a0 100644 --- a/core/jni/AndroidRuntime.cpp +++ b/core/jni/AndroidRuntime.cpp @@ -348,6 +348,15 @@ static int hasDir(const char* dir) return 0; } +static bool hasFile(const char* file) { + struct stat s; + int res = stat(file, &s); + if (res == 0) { + return S_ISREG(s.st_mode); + } + return false; +} + /* * Read the persistent locale. */ @@ -760,10 +769,16 @@ int AndroidRuntime::startVm(JavaVM** pJavaVM, JNIEnv** pEnv) parseCompilerOption("dalvik.vm.image-dex2oat-filter", dex2oatImageCompilerFilterBuf, "--compiler-filter=", "-Ximage-compiler-option"); } + + // Make sure there is a preloaded-classes file. + if (!hasFile("/system/etc/preloaded-classes")) { + ALOGE("Missing preloaded-classes file, /system/etc/preloaded-classes not found: %s\n", + strerror(errno)); + goto bail; + } addOption("-Ximage-compiler-option"); - addOption("--image-classes-zip=/system/framework/framework.jar"); - addOption("-Ximage-compiler-option"); - addOption("--image-classes=preloaded-classes"); + addOption("--image-classes=/system/etc/preloaded-classes"); + property_get("dalvik.vm.image-dex2oat-flags", dex2oatImageFlagsBuf, ""); parseExtraOpts(dex2oatImageFlagsBuf, "-Ximage-compiler-option");