/**
* Returns the index of the parameter declared with the given type, ensuring that there is exactly one such parameter.
*
* @throws NoSuchFieldError if there is no or more than one parameter with that type.
*/
public static int getParameterIndexByType(final Member method, final Class<?> type) {
final Class<?>[] classes = (method instanceof Method) ?
((Method) method).getParameterTypes() : ((Constructor<?>) method).getParameterTypes();
int idx = -1;
for (int i = 0; i < classes.length; ++i) {
if (classes[i] == type) {
if (idx == -1) {
idx = i;
} else {
throw new NoSuchFieldError("More than one parameter of type " + type + " found in " + method);
}
}
}
if (idx != -1) {
return idx;
} else {
throw new NoSuchFieldError("No parameter of type " + type + " found in " + method);
}
}
XposedHelpers.java 文件源码
java
阅读 44
收藏 0
点赞 0
评论 0
项目:AndHook
作者:
评论列表
文章目录