OSDN Git Service

Warn if we see a class whose behavior has changed because of https://android-review...
authorElliott Hughes <enh@google.com>
Fri, 13 Jul 2012 18:41:50 +0000 (11:41 -0700)
committerElliott Hughes <enh@google.com>
Fri, 13 Jul 2012 18:41:50 +0000 (11:41 -0700)
Change-Id: Ic7ca229a92c8d1bd666ecf64209d061301dcb0c9

vm/oo/Class.cpp

index cc31e4e..eb816b0 100644 (file)
@@ -2913,20 +2913,26 @@ static bool createVtable(ClassObject* clazz)
             for (si = 0; si < clazz->super->vtableCount; si++) {
                 Method* superMeth = clazz->vtable[si];
 
-                if (dvmCompareMethodNamesAndProtos(localMeth, superMeth) == 0 &&
-                        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);
-                        goto bail;
+                if (dvmCompareMethodNamesAndProtos(localMeth, superMeth) == 0) {
+                    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);
+                            goto bail;
+                        }
+                        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);
                     }
-                    clazz->vtable[si] = localMeth;
-                    localMeth->methodIndex = (u2) si;
-                    //ALOGV("+++   override %s.%s (slot %d)",
-                    //    clazz->descriptor, localMeth->name, si);
-                    break;
                 }
             }