summaryrefslogtreecommitdiffstats
path: root/runtime/native/dalvik_system_DexFile.cc
diff options
context:
space:
mode:
authorBrian Carlstrom <bdc@google.com>2013-08-12 17:04:14 -0700
committerBrian Carlstrom <bdc@google.com>2013-08-15 10:33:53 -0700
commit7571e8b761ebc2c923525e12ea9fcf07e62cb33e (patch)
tree5d90ecf4d0ba1a72b040a376f227df1ba9278889 /runtime/native/dalvik_system_DexFile.cc
parent2e250c826b3c405d675017efe79e5db3651c9ee6 (diff)
downloadart-7571e8b761ebc2c923525e12ea9fcf07e62cb33e.zip
art-7571e8b761ebc2c923525e12ea9fcf07e62cb33e.tar.gz
art-7571e8b761ebc2c923525e12ea9fcf07e62cb33e.tar.bz2
Add flock(2)ing on dex-cache files to prevent races
Bug: 9071417 Change-Id: I1ee9ff281867f90fba7a8ed8bbf06b33ac29d511
Diffstat (limited to 'runtime/native/dalvik_system_DexFile.cc')
-rw-r--r--runtime/native/dalvik_system_DexFile.cc8
1 files changed, 6 insertions, 2 deletions
diff --git a/runtime/native/dalvik_system_DexFile.cc b/runtime/native/dalvik_system_DexFile.cc
index dc3573d..061dfb8 100644
--- a/runtime/native/dalvik_system_DexFile.cc
+++ b/runtime/native/dalvik_system_DexFile.cc
@@ -84,7 +84,7 @@ class NullableScopedUtfChars {
void operator=(const NullableScopedUtfChars&);
};
-static jint DexFile_openDexFile(JNIEnv* env, jclass, jstring javaSourceName, jstring javaOutputName, jint) {
+static jint DexFile_openDexFileNative(JNIEnv* env, jclass, jstring javaSourceName, jstring javaOutputName, jint) {
ScopedUtfChars sourceName(env, javaSourceName);
if (sourceName.c_str() == NULL) {
return 0;
@@ -141,21 +141,25 @@ static jclass DexFile_defineClassNative(JNIEnv* env, jclass, jstring javaName, j
ScopedObjectAccess soa(env);
const DexFile* dex_file = toDexFile(cookie);
if (dex_file == NULL) {
+ VLOG(class_linker) << "Failed to find dex_file";
return NULL;
}
ScopedUtfChars class_name(env, javaName);
if (class_name.c_str() == NULL) {
+ VLOG(class_linker) << "Failed to find class_name";
return NULL;
}
const std::string descriptor(DotToDescriptor(class_name.c_str()));
const DexFile::ClassDef* dex_class_def = dex_file->FindClassDef(descriptor);
if (dex_class_def == NULL) {
+ VLOG(class_linker) << "Failed to find dex_class_def";
return NULL;
}
ClassLinker* class_linker = Runtime::Current()->GetClassLinker();
class_linker->RegisterDexFile(*dex_file);
mirror::ClassLoader* class_loader = soa.Decode<mirror::ClassLoader*>(javaLoader);
mirror::Class* result = class_linker->DefineClass(descriptor, class_loader, *dex_file, *dex_class_def);
+ VLOG(class_linker) << "DexFile_defineClassNative returning " << result;
return soa.AddLocalReference<jclass>(result);
}
@@ -300,7 +304,7 @@ static JNINativeMethod gMethods[] = {
NATIVE_METHOD(DexFile, defineClassNative, "(Ljava/lang/String;Ljava/lang/ClassLoader;I)Ljava/lang/Class;"),
NATIVE_METHOD(DexFile, getClassNameList, "(I)[Ljava/lang/String;"),
NATIVE_METHOD(DexFile, isDexOptNeeded, "(Ljava/lang/String;)Z"),
- NATIVE_METHOD(DexFile, openDexFile, "(Ljava/lang/String;Ljava/lang/String;I)I"),
+ NATIVE_METHOD(DexFile, openDexFileNative, "(Ljava/lang/String;Ljava/lang/String;I)I"),
};
void register_dalvik_system_DexFile(JNIEnv* env) {