package com.google.android.gms.internal.play_billing; import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; import java.util.ServiceConfigurationError; import java.util.ServiceLoader; import java.util.logging.Level; import java.util.logging.Logger; /* loaded from: classes.dex */ public abstract class zzcl { static zzcd zzb(Class cls) { String format; ClassLoader classLoader = zzcl.class.getClassLoader(); if (cls.equals(zzcd.class)) { format = "com.google.protobuf.BlazeGeneratedExtensionRegistryLiteLoader"; } else { if (!cls.getPackage().equals(zzcl.class.getPackage())) { throw new IllegalArgumentException(cls.getName()); } format = String.format("%s.BlazeGenerated%sLoader", cls.getPackage().getName(), cls.getSimpleName()); } try { try { try { try { return (zzcd) cls.cast(((zzcl) Class.forName(format, true, classLoader).getConstructor(new Class[0]).newInstance(new Object[0])).zza()); } catch (InstantiationException e10) { throw new IllegalStateException(e10); } catch (NoSuchMethodException e11) { throw new IllegalStateException(e11); } } catch (InvocationTargetException e12) { throw new IllegalStateException(e12); } } catch (IllegalAccessException e13) { throw new IllegalStateException(e13); } } catch (ClassNotFoundException unused) { Iterator it = ServiceLoader.load(zzcl.class, classLoader).iterator(); ArrayList arrayList = new ArrayList(); while (it.hasNext()) { try { arrayList.add((zzcd) cls.cast(((zzcl) it.next()).zza())); } catch (ServiceConfigurationError e14) { Logger.getLogger(zzby.class.getName()).logp(Level.SEVERE, "com.google.protobuf.GeneratedExtensionRegistryLoader", "load", "Unable to load ".concat(cls.getSimpleName()), (Throwable) e14); } } if (arrayList.size() == 1) { return (zzcd) arrayList.get(0); } if (arrayList.size() == 0) { return null; } try { return (zzcd) cls.getMethod("combine", Collection.class).invoke(null, arrayList); } catch (IllegalAccessException e15) { throw new IllegalStateException(e15); } catch (NoSuchMethodException e16) { throw new IllegalStateException(e16); } catch (InvocationTargetException e17) { throw new IllegalStateException(e17); } } } protected abstract zzcd zza(); }