package com.google.android.gms.internal.ads;

import java.io.IOException;

/* JADX INFO: loaded from: classes2.dex */
public abstract class ba2 implements Cloneable {
    public static void b(int i10, jb2 jb2Var) {
        int size = jb2Var.size() - i10;
        String strG = com.bytedance.sdk.component.adexpress.dynamic.dynamicview.b.g(new StringBuilder(String.valueOf(size).length() + 26), "Element at index ", size, " is null.");
        int size2 = jb2Var.size();
        while (true) {
            size2--;
            if (size2 < i10) {
                throw new NullPointerException(strG);
            }
            jb2Var.remove(size2);
        }
    }

    public final void a(byte[] bArr, ua2 ua2Var) throws zzicg {
        int length = bArr.length;
        ab2 ab2Var = (ab2) this;
        ab2Var.c();
        try {
            dc2.f10372c.b(ab2Var.f8617b.getClass()).i(ab2Var.f8617b, bArr, 0, length, new ga2(ua2Var));
        } catch (zzicg e10) {
            throw e10;
        } catch (IOException e11) {
            throw new RuntimeException("Reading from byte array should not throw IOException.", e11);
        } catch (IndexOutOfBoundsException unused) {
            throw new zzicg("While parsing a protocol message, the input ended unexpectedly in the middle of a field.  This could mean either that the input has been truncated or that an embedded message misreported its own length.");
        }
    }
}
