OSDN Git Service

Revert "Don't enforce access checks for overloading for targetSdkVersion < 17."
authorElliott Hughes <enh@google.com>
Sat, 13 Oct 2012 00:47:06 +0000 (17:47 -0700)
committerAndroid (Google) Code Review <android-gerrit@google.com>
Sat, 13 Oct 2012 00:47:06 +0000 (17:47 -0700)
This reverts commit 0fe885202fc2d1e7f3d34c99ae3487a9a6387be1

May be causing http://b/7343420, though I can't reproduce that crash.

Change-Id: Ia3d2a1507602d07699d1f9914e734cc813f97518

vm/Globals.h
vm/native/dalvik_system_VMRuntime.cpp
vm/oo/Class.cpp

index 3a90ddf..565c92a 100644 (file)
@@ -124,8 +124,6 @@ struct DvmGlobals {
     void        (*abortHook)(void);
     bool        (*isSensitiveThreadHook)(void);
 
-    int targetSdkVersion;
-
     int         jniGrefLimit;       // 0 means no limit
     char*       jniTrace;
     bool        reduceSignals;
index 0195a8c..72bad29 100644 (file)
@@ -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".
-    gDvm.targetSdkVersion = args[1];
-    if (gDvm.targetSdkVersion > 0 && gDvm.targetSdkVersion <= 13 /* honeycomb-mr2 */) {
+    int targetSdkVersion = args[1];
+    if (targetSdkVersion > 0 && 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...", gDvm.targetSdkVersion);
+        ALOGI("Turning on JNI app bug workarounds for target SDK version %i...", targetSdkVersion);
         gDvmJni.workAroundAppJniBugs = true;
     }
     RETURN_VOID();
index 17c9ff8..eb816b0 100644 (file)
@@ -2914,30 +2914,24 @@ static bool createVtable(ClassObject* clazz)
                 Method* superMeth = clazz->vtable[si];
 
                 if (dvmCompareMethodNamesAndProtos(localMeth, superMeth) == 0) {
-                    // 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 (dvmCheckMethodAccess(clazz, superMeth)) {
+                        /* verify */
                         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);
                     }
                 }
             }