summaryrefslogtreecommitdiffstats
path: root/src/dalvik_system_DexFile.cc
diff options
context:
space:
mode:
authorjeffhao <jeffhao@google.com>2012-01-31 16:14:17 -0800
committerjeffhao <jeffhao@google.com>2012-01-31 17:48:30 -0800
commitf6174e8a1566bb357e82506f7ec97dc359c90eb2 (patch)
treeb74b1fc81d0dc0b2f2da7ab6f5187493f15a0b66 /src/dalvik_system_DexFile.cc
parent4d9716c19cc25911e639272048abd0d6702bb082 (diff)
downloadart-f6174e8a1566bb357e82506f7ec97dc359c90eb2.zip
art-f6174e8a1566bb357e82506f7ec97dc359c90eb2.tar.gz
art-f6174e8a1566bb357e82506f7ec97dc359c90eb2.tar.bz2
Fix to prevent a dex file from being verified multiple times.
Instead of verifying a dex file whenever one is initialized, they're now verified when not opened from memory. Also, the way dalvik_system_DexFile opens dex files has been changed to check for an existing oat file and get the corresponding dex file from there instead. Change-Id: I75fc26247150107d628e2c4e364ef8a53fbf9481
Diffstat (limited to 'src/dalvik_system_DexFile.cc')
-rw-r--r--src/dalvik_system_DexFile.cc21
1 files changed, 6 insertions, 15 deletions
diff --git a/src/dalvik_system_DexFile.cc b/src/dalvik_system_DexFile.cc
index dd91eac..67cb49b 100644
--- a/src/dalvik_system_DexFile.cc
+++ b/src/dalvik_system_DexFile.cc
@@ -90,7 +90,10 @@ static jint DexFile_openDexFile(JNIEnv* env, jclass, jstring javaSourceName, jst
}
const DexFile* dex_file;
if (outputName.c_str() == NULL) {
- dex_file = DexFile::Open(sourceName.c_str(), "");
+ dex_file = Runtime::Current()->GetClassLinker()->FindDexFileFromDexLocation(sourceName.c_str());
+ if (dex_file == NULL) {
+ dex_file = DexFile::Open(sourceName.c_str(), "");
+ }
} else {
// Sanity check the arguments.
if (!IsValidZipFilename(sourceName.c_str()) || !IsValidDexFilename(outputName.c_str())) {
@@ -233,20 +236,8 @@ jboolean DexFile_isDexOptNeeded(JNIEnv* env, jclass, jstring javaFilename) {
}
}
- UniquePtr<const DexFile> dex_file(DexFile::Open(filename.c_str(), ""));
- if (dex_file.get() == NULL) {
- return JNI_TRUE;
- }
-
- const OatFile* oat_file = class_linker->FindOatFileForDexFile(*dex_file.get());
- if (oat_file == NULL) {
- return JNI_TRUE;
- }
- const OatFile::OatDexFile* oat_dex_file = oat_file->GetOatDexFile(dex_file->GetLocation());
- if (oat_dex_file == NULL) {
- return JNI_TRUE;
- }
- if (oat_dex_file->GetDexFileChecksum() != dex_file->GetHeader().checksum_) {
+ const DexFile* dex_file = class_linker->FindDexFileFromDexLocation(filename.c_str());
+ if (dex_file == NULL) {
return JNI_TRUE;
}
return JNI_FALSE;