public static int getParamIndex(Class<?> clazz, Method method, String paramName, int defaultValue) {
    try {
      String cacheKey = clazz.getName() + method.toString();
      Integer cachedIndex = METHOD_PARAM_INDEX_CACHE.get(cacheKey);
      if (cachedIndex != null) return cachedIndex;

      Class<?>[] parameters = method.getParameterTypes();
      for (int i = 0; i < parameters.length; i++) {
        Class<?> p = parameters[i];
        XLog.i("getParamIndex, name = "+ p.getName());
        if (paramName.equals(p.getName())) {
          METHOD_PARAM_INDEX_CACHE.put(cacheKey, i);
          return i;
        }
      }

      METHOD_PARAM_INDEX_CACHE.put(cacheKey, defaultValue);
      return defaultValue;
    } catch (Throwable e) {
      XLog.e("getParamIndexOr error", e);
      return defaultValue;
    }
  }
This may not work on Android class, param name may not present.
android/android_framework/base/src/main/java/util/XposedHelpersExt.java