Skip to content
This repository has been archived by the owner on Jun 1, 2023. It is now read-only.

Commit

Permalink
v38: Make findMethodBestMatch() find protected methods from superclasses
Browse files Browse the repository at this point in the history
  • Loading branch information
rovo89 committed Nov 1, 2013
1 parent a18f4b9 commit d4f7fe2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion assets/VERSION
@@ -1 +1 @@
37
38
15 changes: 11 additions & 4 deletions src/de/robv/android/xposed/XposedHelpers.java
Expand Up @@ -8,6 +8,7 @@
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
Expand Down Expand Up @@ -249,9 +250,14 @@ public static Method findMethodBestMatch(Class<?> clazz, String methodName, Clas
} catch (NoSuchMethodError ignored) {}

Method bestMatch = null;
for (int i = 0; i < 2; i++) {
Method[] methods = (i == 0) ? clazz.getDeclaredMethods() : clazz.getMethods();
for (Method method : methods) {
Class<?> clz = clazz;
boolean considerPrivateMethods = true;
do {
for (Method method : clz.getDeclaredMethods()) {
// don't consider private methods of superclasses
if (!considerPrivateMethods && Modifier.isPrivate(method.getModifiers()))
continue;

// compare name and parameters
if (method.getName().equals(methodName) && ClassUtils.isAssignable(parameterTypes, method.getParameterTypes(), true)) {
// get accessible version of method
Expand All @@ -263,7 +269,8 @@ public static Method findMethodBestMatch(Class<?> clazz, String methodName, Clas
}
}
}
}
considerPrivateMethods = false;
} while ((clz = clz.getSuperclass()) != null);

if (bestMatch != null) {
bestMatch.setAccessible(true);
Expand Down

0 comments on commit d4f7fe2

Please sign in to comment.