package j;

import android.os.Build;
import android.os.Handler;
import android.os.Looper;
import j.c;
import java.lang.invoke.MethodHandles;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.util.concurrent.Executor;
import javax.annotation.Nullable;
import org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement;

/* JADX INFO: compiled from: Platform.java */
/* JADX INFO: loaded from: classes.dex */
class k {
    private static final k a = c();

    /* JADX INFO: compiled from: Platform.java */
    static class a extends k {

        /* JADX INFO: renamed from: j.k$a$a, reason: collision with other inner class name */
        /* JADX INFO: compiled from: Platform.java */
        static class ExecutorC0138a implements Executor {

            /* JADX INFO: renamed from: b, reason: collision with root package name */
            private final Handler f4355b = new Handler(Looper.getMainLooper());

            ExecutorC0138a() {
            }

            @Override // java.util.concurrent.Executor
            public void execute(Runnable runnable) {
                this.f4355b.post(runnable);
            }
        }

        a() {
        }

        @Override // j.k
        c.a a(@Nullable Executor executor) {
            if (executor != null) {
                return new g(executor);
            }
            throw new AssertionError();
        }

        @Override // j.k
        public Executor b() {
            return new ExecutorC0138a();
        }
    }

    /* JADX INFO: compiled from: Platform.java */
    @IgnoreJRERequirement
    static class b extends k {
        b() {
        }

        @Override // j.k
        Object e(Method method, Class<?> cls, Object obj, @Nullable Object... objArr) throws Throwable {
            Constructor declaredConstructor = MethodHandles.Lookup.class.getDeclaredConstructor(Class.class, Integer.TYPE);
            declaredConstructor.setAccessible(true);
            return ((MethodHandles.Lookup) declaredConstructor.newInstance(cls, -1)).unreflectSpecial(method, cls).bindTo(obj).invokeWithArguments(objArr);
        }

        @Override // j.k
        boolean f(Method method) {
            return method.isDefault();
        }
    }

    k() {
    }

    private static k c() {
        try {
            Class.forName("android.os.Build");
            if (Build.VERSION.SDK_INT != 0) {
                return new a();
            }
        } catch (ClassNotFoundException unused) {
        }
        try {
            Class.forName("java.util.Optional");
            return new b();
        } catch (ClassNotFoundException unused2) {
            return new k();
        }
    }

    static k d() {
        return a;
    }

    c.a a(@Nullable Executor executor) {
        return executor != null ? new g(executor) : f.a;
    }

    @Nullable
    Executor b() {
        return null;
    }

    @Nullable
    Object e(Method method, Class<?> cls, Object obj, @Nullable Object... objArr) throws Throwable {
        throw new UnsupportedOperationException();
    }

    boolean f(Method method) {
        return false;
    }
}
