summaryrefslogtreecommitdiffstats
path: root/tools/apicheck
diff options
context:
space:
mode:
authorVasu Nori <vnori@google.com>2010-04-21 23:43:08 -0700
committerVasu Nori <vnori@google.com>2010-04-21 23:43:08 -0700
commit65dd8f4ceda64b1e4a4c326d771bd74263cef0cb (patch)
tree0f148773fbff89f1a5962a0363673df723ebde61 /tools/apicheck
parent475089cc25ab0cfabe0243a91c5a3d65ca4f708d (diff)
downloadbuild-65dd8f4ceda64b1e4a4c326d771bd74263cef0cb.zip
build-65dd8f4ceda64b1e4a4c326d771bd74263cef0cb.tar.gz
build-65dd8f4ceda64b1e4a4c326d771bd74263cef0cb.tar.bz2
fix searching of ancestors for removed methods
Change-Id: I5c1792c90e6960c248beb44f995cb4440360025d
Diffstat (limited to 'tools/apicheck')
-rw-r--r--tools/apicheck/src/com/android/apicheck/ClassInfo.java36
1 files changed, 15 insertions, 21 deletions
diff --git a/tools/apicheck/src/com/android/apicheck/ClassInfo.java b/tools/apicheck/src/com/android/apicheck/ClassInfo.java
index 2555ea4..962a316 100644
--- a/tools/apicheck/src/com/android/apicheck/ClassInfo.java
+++ b/tools/apicheck/src/com/android/apicheck/ClassInfo.java
@@ -86,41 +86,35 @@ public class ClassInfo {
return mIsFinal;
}
- // Find a superclass implementation of the given method. Looking at our superclass
- // instead of at 'this' is unusual, but it fits the point-of-call demands well.
- public MethodInfo overriddenMethod(MethodInfo candidate) {
- if (mSuperClass == null) {
+ // Find a superclass implementation of the given method.
+ public static MethodInfo overriddenMethod(MethodInfo candidate, ClassInfo newClassObj) {
+ if (newClassObj == null) {
return null;
}
-
- // does our immediate superclass have it?
- ClassInfo sup = mSuperClass;
- for (MethodInfo mi : sup.mMethods.values()) {
+ for (MethodInfo mi : newClassObj.mMethods.values()) {
if (mi.matches(candidate)) {
// found it
return mi;
}
}
- // no, so recurse
- if (sup.mSuperClass != null) {
- return mSuperClass.overriddenMethod(candidate);
- }
-
- // no parent, so we just don't have it
- return null;
+ // not found here. recursively search ancestors
+ return ClassInfo.overriddenMethod(candidate, newClassObj.mSuperClass);
}
// Find a superinterface declaration of the given method.
- public MethodInfo interfaceMethod(MethodInfo candidate) {
- for (ClassInfo interfaceInfo : mInterfaces) {
+ public static MethodInfo interfaceMethod(MethodInfo candidate, ClassInfo newClassObj) {
+ if (newClassObj == null) {
+ return null;
+ }
+ for (ClassInfo interfaceInfo : newClassObj.mInterfaces) {
for (MethodInfo mi : interfaceInfo.mMethods.values()) {
if (mi.matches(candidate)) {
return mi;
}
}
}
- return (mSuperClass != null) ? mSuperClass.interfaceMethod(candidate) : null;
+ return ClassInfo.interfaceMethod(candidate, newClassObj.mSuperClass);
}
public boolean isConsistent(ClassInfo cl) {
@@ -159,9 +153,9 @@ public class ClassInfo {
* Check our ancestry to see if there's an inherited version that still
* fulfills the API requirement.
*/
- MethodInfo mi = mInfo.containingClass().overriddenMethod(mInfo);
+ MethodInfo mi = ClassInfo.overriddenMethod(mInfo, cl);
if (mi == null) {
- mi = mInfo.containingClass().interfaceMethod(mInfo);
+ mi = ClassInfo.interfaceMethod(mInfo, cl);
}
if (mi == null) {
Errors.error(Errors.REMOVED_METHOD, mInfo.position(),
@@ -175,7 +169,7 @@ public class ClassInfo {
/* Similarly to the above, do not fail if this "new" method is
* really an override of an existing superclass method.
*/
- MethodInfo mi = mInfo.containingClass().overriddenMethod(mInfo);
+ MethodInfo mi = ClassInfo.overriddenMethod(mInfo, cl);
if (mi == null) {
Errors.error(Errors.ADDED_METHOD, mInfo.position(),
"Added public method " + mInfo.qualifiedName());