summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2012-10-11 18:17:50 -0700
committerElliott Hughes <enh@google.com>2012-10-11 18:26:31 -0700
commit0fe885202fc2d1e7f3d34c99ae3487a9a6387be1 (patch)
treeba77ae091157f469bbf3f8aa0a5cd2931fa6cae6
parent9c789541c5a37dc8c5d12d98b8db74def61e26db (diff)
downloadandroid_dalvik-0fe885202fc2d1e7f3d34c99ae3487a9a6387be1.tar.gz
android_dalvik-0fe885202fc2d1e7f3d34c99ae3487a9a6387be1.tar.bz2
android_dalvik-0fe885202fc2d1e7f3d34c99ae3487a9a6387be1.zip
Don't enforce access checks for overloading for targetSdkVersion < 17.
Still warn, and enforce the missing check for targetSdkVersion >= 17. Bug: 7301030 Change-Id: I8189fcbf222f331b1f80a156b01082d61f1f9362
-rw-r--r--vm/Globals.h2
-rw-r--r--vm/native/dalvik_system_VMRuntime.cpp6
-rw-r--r--vm/oo/Class.cpp24
3 files changed, 20 insertions, 12 deletions
diff --git a/vm/Globals.h b/vm/Globals.h
index 565c92a65..3a90ddf89 100644
--- a/vm/Globals.h
+++ b/vm/Globals.h
@@ -124,6 +124,8 @@ struct DvmGlobals {
void (*abortHook)(void);
bool (*isSensitiveThreadHook)(void);
+ int targetSdkVersion;
+
int jniGrefLimit; // 0 means no limit
char* jniTrace;
bool reduceSignals;
diff --git a/vm/native/dalvik_system_VMRuntime.cpp b/vm/native/dalvik_system_VMRuntime.cpp
index 72bad2971..0195a8c05 100644
--- a/vm/native/dalvik_system_VMRuntime.cpp
+++ b/vm/native/dalvik_system_VMRuntime.cpp
@@ -191,10 +191,10 @@ static void Dalvik_dalvik_system_VMRuntime_setTargetSdkVersion(const u4* args,
// This is the target SDK version of the app we're about to run.
// Note that this value may be CUR_DEVELOPMENT (10000).
// Note that this value may be 0, meaning "current".
- int targetSdkVersion = args[1];
- if (targetSdkVersion > 0 && targetSdkVersion <= 13 /* honeycomb-mr2 */) {
+ gDvm.targetSdkVersion = args[1];
+ if (gDvm.targetSdkVersion > 0 && gDvm.targetSdkVersion <= 13 /* honeycomb-mr2 */) {
// TODO: running with CheckJNI should override this and force you to obey the strictest rules.
- ALOGI("Turning on JNI app bug workarounds for target SDK version %i...", targetSdkVersion);
+ ALOGI("Turning on JNI app bug workarounds for target SDK version %i...", gDvm.targetSdkVersion);
gDvmJni.workAroundAppJniBugs = true;
}
RETURN_VOID();
diff --git a/vm/oo/Class.cpp b/vm/oo/Class.cpp
index eb816b0f3..17c9ff882 100644
--- a/vm/oo/Class.cpp
+++ b/vm/oo/Class.cpp
@@ -2914,24 +2914,30 @@ static bool createVtable(ClassObject* clazz)
Method* superMeth = clazz->vtable[si];
if (dvmCompareMethodNamesAndProtos(localMeth, superMeth) == 0) {
- if (dvmCheckMethodAccess(clazz, superMeth)) {
- /* verify */
+ // Some apps were relying on us not checking access: http://b/7301030
+ bool isPreJbMr1 = (gDvm.targetSdkVersion > 0 && gDvm.targetSdkVersion < 17);
+ bool isAccessible = dvmCheckMethodAccess(clazz, superMeth);
+ if (isPreJbMr1 || isAccessible) {
if (dvmIsFinalMethod(superMeth)) {
ALOGW("Method %s.%s overrides final %s.%s",
- localMeth->clazz->descriptor, localMeth->name,
- superMeth->clazz->descriptor, superMeth->name);
+ localMeth->clazz->descriptor, localMeth->name,
+ superMeth->clazz->descriptor, superMeth->name);
goto bail;
}
+
+ // Warn if we may have just worked around broken code...
+ if (!isAccessible) {
+ ALOGW("in older Android releases, method %s.%s would have incorrectly "
+ "overridden package-private method with same name in %s",
+ localMeth->clazz->descriptor, localMeth->name,
+ superMeth->clazz->descriptor);
+ }
+
clazz->vtable[si] = localMeth;
localMeth->methodIndex = (u2) si;
//ALOGV("+++ override %s.%s (slot %d)",
// clazz->descriptor, localMeth->name, si);
break;
- } else {
- ALOGW("in older versions of dalvik, method %s.%s would have incorrectly "
- "overridden package-private method with same name in %s",
- localMeth->clazz->descriptor, localMeth->name,
- superMeth->clazz->descriptor);
}
}
}