package com.kakao.util.helper;

import X.AnonymousClass3GY;
import android.util.Pair;
import com.bytedance.covode.number.Covode;
import java.lang.reflect.Method;

public final class MethodInvoker {
    static {
        Covode.recordClassIndex(45994);
    }

    public static Object com_kakao_util_helper_MethodInvoker_java_lang_reflect_Method_invoke(Method method, Object obj, Object[] objArr) {
        AnonymousClass3GY.LIZ(110000);
        Method method2 = method;
        Pair<Boolean, Object> LIZ = AnonymousClass3GY.LIZ((Object) null, method2, new Object[]{obj, objArr}, 110000, "java.lang.Object", true, 678533230, 2);
        return ((Boolean) LIZ.first).booleanValue() ? LIZ.second : method2.invoke(obj, objArr);
    }

    public static Method findMethod(String str, Method[] methodArr) {
        for (Method method : methodArr) {
            if (method.getName().equals(str)) {
                method.setAccessible(true);
                return method;
            }
        }
        return null;
    }

    public static void invoke(Object obj, String str, Object... objArr) {
        Method findMethod;
        if (obj != null) {
            Class cls = obj.getClass();
            while (!cls.equals(Object.class)) {
                Method[] declaredMethods = cls.getDeclaredMethods();
                if (declaredMethods == null || (findMethod = findMethod(str, declaredMethods)) == null) {
                    cls = cls.getSuperclass();
                } else {
                    com_kakao_util_helper_MethodInvoker_java_lang_reflect_Method_invoke(findMethod, obj, objArr);
                    return;
                }
            }
            return;
        }
        throw new RuntimeException("methodOwnerClass is null.");
    }
}
