package com.google.gson;

import com.bytedance.covode.number.Covode;
import com.google.gson.c.a;
import com.google.gson.c.b;
import com.google.gson.c.d;
import com.google.gson.internal.k;
import java.io.IOException;
import java.io.Reader;
import java.io.StringReader;

public final class o {
    static {
        Covode.recordClassIndex(45515);
    }

    public final j LIZ(String str) {
        return LIZ((Reader) new StringReader(str));
    }

    /* JADX WARNING: type inference failed for: r0v0, types: [java.lang.Throwable, com.google.gson.s] */
    /* JADX WARNING: type inference failed for: r0v1, types: [java.lang.Throwable, com.google.gson.k] */
    /* JADX WARNING: type inference failed for: r0v2, types: [java.lang.Throwable, com.google.gson.s] */
    /* JADX WARNING: type inference failed for: r1v5, types: [java.lang.Throwable, com.google.gson.s] */
    private j LIZ(Reader reader) {
        try {
            a aVar = new a(reader);
            j LIZ = LIZ(aVar);
            if (!(LIZ instanceof l)) {
                if (aVar.LJFF() != b.END_DOCUMENT) {
                    throw new s("Did not consume the entire document.");
                }
            }
            return LIZ;
        } catch (d e) {
            throw new s((Throwable) e);
        } catch (IOException e2) {
            throw new k((Throwable) e2);
        } catch (NumberFormatException e3) {
            throw new s((Throwable) e3);
        }
    }

    public final j LIZ(a aVar) {
        boolean z = aVar.LIZ;
        aVar.LIZ = true;
        try {
            j LIZ = k.LIZ(aVar);
            aVar.LIZ = z;
            return LIZ;
        } catch (StackOverflowError e) {
            throw new n("Failed parsing JSON source: " + aVar + " to Json", e);
        } catch (OutOfMemoryError e2) {
            throw new n("Failed parsing JSON source: " + aVar + " to Json", e2);
        } catch (Throwable th) {
            aVar.LIZ = z;
            throw th;
        }
    }
}
