in core/src/main/java/org/apache/sling/testing/mock/osgi/OsgiServiceUtil.java [273:291]
private static Method getMethod(Class clazz, String methodName, Class<?>[] types) {
Method[] methods = clazz.getDeclaredMethods();
for (Method method : methods) {
if (StringUtils.equals(method.getName(), methodName) && method.getParameterTypes().length==types.length) {
boolean foundMismatch = false;
for (int i=0; i<types.length; i++) {
if (!((method.getParameterTypes()[i]==types[i])
|| (types[i]==Annotation.class && method.getParameterTypes()[i].isAnnotation()))) {
foundMismatch = true;
break;
}
}
if (!foundMismatch) {
return method;
}
}
}
return null;
}