summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--runtime/native/dalvik_system_DexFile.cc37
1 files changed, 37 insertions, 0 deletions
diff --git a/runtime/native/dalvik_system_DexFile.cc b/runtime/native/dalvik_system_DexFile.cc
index d4ad0ea0bf..b2349fc23c 100644
--- a/runtime/native/dalvik_system_DexFile.cc
+++ b/runtime/native/dalvik_system_DexFile.cc
@@ -552,6 +552,41 @@ static jboolean DexFile_isBackedByOatFile(JNIEnv* env, jclass, jobject cookie) {
return oat_file != nullptr;
}
+static jstring DexFile_getDexFileOutputPath(JNIEnv* env,
+ jclass,
+ jstring javaFilename,
+ jstring javaInstructionSet) {
+ ScopedUtfChars filename(env, javaFilename);
+ if (env->ExceptionCheck()) {
+ return nullptr;
+ }
+
+ ScopedUtfChars instruction_set(env, javaInstructionSet);
+ if (env->ExceptionCheck()) {
+ return nullptr;
+ }
+
+ const InstructionSet target_instruction_set = GetInstructionSetFromString(
+ instruction_set.c_str());
+ if (target_instruction_set == kNone) {
+ ScopedLocalRef<jclass> iae(env, env->FindClass("java/lang/IllegalArgumentException"));
+ std::string message(StringPrintf("Instruction set %s is invalid.", instruction_set.c_str()));
+ env->ThrowNew(iae.get(), message.c_str());
+ return nullptr;
+ }
+
+ OatFileAssistant oat_file_assistant(filename.c_str(),
+ target_instruction_set,
+ false /* load_executable */);
+
+ std::unique_ptr<OatFile> best_oat_file = oat_file_assistant.GetBestOatFile();
+ if (best_oat_file == nullptr) {
+ return nullptr;
+ }
+
+ return env->NewStringUTF(best_oat_file->GetLocation().c_str());
+}
+
static JNINativeMethod gMethods[] = {
NATIVE_METHOD(DexFile, closeDexFile, "(Ljava/lang/Object;)Z"),
NATIVE_METHOD(DexFile,
@@ -579,6 +614,8 @@ static JNINativeMethod gMethods[] = {
"(Ljava/lang/String;)Ljava/lang/String;"),
NATIVE_METHOD(DexFile, isBackedByOatFile, "(Ljava/lang/Object;)Z"),
NATIVE_METHOD(DexFile, getDexFileStatus,
+ "(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;"),
+ NATIVE_METHOD(DexFile, getDexFileOutputPath,
"(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;")
};