SerializationUtils.smali

.class public Lorg/apache/commons/lang3/SerializationUtils;
.super Ljava/lang/Object;
.source "SerializationUtils.java"


# annotations
.annotation system Ldalvik/annotation/MemberClasses;
    value = {
        Lorg/apache/commons/lang3/SerializationUtils$ClassLoaderAwareObjectInputStream;
    }
.end annotation


# direct methods
.method public constructor <init>()V
    .registers 1

    .line 59
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    return-void
.end method

.method public static clone(Ljava/io/Serializable;)Ljava/io/Serializable;
    .registers 5
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "<T::",
            "Ljava/io/Serializable;",
            ">(TT;)TT;"
        }
    .end annotation

    const-string v0, "IOException on closing cloned object data InputStream."

    const/4 v1, 0x0

    if-nez p0, :cond_6

    return-object v1

    .line 82
    :cond_6
    invoke-static {p0}, Lorg/apache/commons/lang3/SerializationUtils;->serialize(Ljava/io/Serializable;)[B

    move-result-object v2

    .line 83
    new-instance v3, Ljava/io/ByteArrayInputStream;

    invoke-direct {v3, v2}, Ljava/io/ByteArrayInputStream;-><init>([B)V

    .line 88
    :try_start_f
    new-instance v2, Lorg/apache/commons/lang3/SerializationUtils$ClassLoaderAwareObjectInputStream;

    invoke-virtual {p0}, Ljava/lang/Object;->getClass()Ljava/lang/Class;

    move-result-object p0

    invoke-virtual {p0}, Ljava/lang/Class;->getClassLoader()Ljava/lang/ClassLoader;

    move-result-object p0

    invoke-direct {v2, v3, p0}, Lorg/apache/commons/lang3/SerializationUtils$ClassLoaderAwareObjectInputStream;-><init>(Ljava/io/InputStream;Ljava/lang/ClassLoader;)V
    :try_end_1c
    .catch Ljava/lang/ClassNotFoundException; {:try_start_f .. :try_end_1c} :catch_41
    .catch Ljava/io/IOException; {:try_start_f .. :try_end_1c} :catch_38
    .catchall {:try_start_f .. :try_end_1c} :catchall_36

    .line 95
    :try_start_1c
    invoke-virtual {v2}, Lorg/apache/commons/lang3/SerializationUtils$ClassLoaderAwareObjectInputStream;->readObject()Ljava/lang/Object;

    move-result-object p0

    check-cast p0, Ljava/io/Serializable;
    :try_end_22
    .catch Ljava/lang/ClassNotFoundException; {:try_start_1c .. :try_end_22} :catch_33
    .catch Ljava/io/IOException; {:try_start_1c .. :try_end_22} :catch_30
    .catchall {:try_start_1c .. :try_end_22} :catchall_2d

    .line 105
    :try_start_22
    invoke-virtual {v2}, Lorg/apache/commons/lang3/SerializationUtils$ClassLoaderAwareObjectInputStream;->close()V
    :try_end_25
    .catch Ljava/io/IOException; {:try_start_22 .. :try_end_25} :catch_26

    return-object p0

    :catch_26
    move-exception p0

    .line 108
    new-instance v1, Lorg/apache/commons/lang3/SerializationException;

    invoke-direct {v1, v0, p0}, Lorg/apache/commons/lang3/SerializationException;-><init>(Ljava/lang/String;Ljava/lang/Throwable;)V

    throw v1

    :catchall_2d
    move-exception p0

    move-object v1, v2

    goto :goto_4a

    :catch_30
    move-exception p0

    move-object v1, v2

    goto :goto_39

    :catch_33
    move-exception p0

    move-object v1, v2

    goto :goto_42

    :catchall_36
    move-exception p0

    goto :goto_4a

    :catch_38
    move-exception p0

    .line 101
    :goto_39
    :try_start_39
    new-instance v2, Lorg/apache/commons/lang3/SerializationException;

    const-string v3, "IOException while reading cloned object data"

    invoke-direct {v2, v3, p0}, Lorg/apache/commons/lang3/SerializationException;-><init>(Ljava/lang/String;Ljava/lang/Throwable;)V

    throw v2

    :catch_41
    move-exception p0

    .line 99
    :goto_42
    new-instance v2, Lorg/apache/commons/lang3/SerializationException;

    const-string v3, "ClassNotFoundException while reading cloned object data"

    invoke-direct {v2, v3, p0}, Lorg/apache/commons/lang3/SerializationException;-><init>(Ljava/lang/String;Ljava/lang/Throwable;)V

    throw v2
    :try_end_4a
    .catchall {:try_start_39 .. :try_end_4a} :catchall_36

    :goto_4a
    if-eqz v1, :cond_57

    .line 105
    :try_start_4c
    invoke-virtual {v1}, Lorg/apache/commons/lang3/SerializationUtils$ClassLoaderAwareObjectInputStream;->close()V
    :try_end_4f
    .catch Ljava/io/IOException; {:try_start_4c .. :try_end_4f} :catch_50

    goto :goto_57

    :catch_50
    move-exception p0

    .line 108
    new-instance v1, Lorg/apache/commons/lang3/SerializationException;

    invoke-direct {v1, v0, p0}, Lorg/apache/commons/lang3/SerializationException;-><init>(Ljava/lang/String;Ljava/lang/Throwable;)V

    throw v1

    :cond_57
    :goto_57
    throw p0
.end method

.method public static deserialize(Ljava/io/InputStream;)Ljava/lang/Object;
    .registers 3
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "<T:",
            "Ljava/lang/Object;",
            ">(",
            "Ljava/io/InputStream;",
            ")TT;"
        }
    .end annotation

    if-eqz p0, :cond_39

    const/4 v0, 0x0

    .line 221
    :try_start_3
    new-instance v1, Ljava/io/ObjectInputStream;

    invoke-direct {v1, p0}, Ljava/io/ObjectInputStream;-><init>(Ljava/io/InputStream;)V
    :try_end_8
    .catch Ljava/lang/ClassCastException; {:try_start_3 .. :try_end_8} :catch_2c
    .catch Ljava/lang/ClassNotFoundException; {:try_start_3 .. :try_end_8} :catch_25
    .catch Ljava/io/IOException; {:try_start_3 .. :try_end_8} :catch_1e
    .catchall {:try_start_3 .. :try_end_8} :catchall_1c

    .line 223
    :try_start_8
    invoke-virtual {v1}, Ljava/io/ObjectInputStream;->readObject()Ljava/lang/Object;

    move-result-object p0
    :try_end_c
    .catch Ljava/lang/ClassCastException; {:try_start_8 .. :try_end_c} :catch_19
    .catch Ljava/lang/ClassNotFoundException; {:try_start_8 .. :try_end_c} :catch_16
    .catch Ljava/io/IOException; {:try_start_8 .. :try_end_c} :catch_13
    .catchall {:try_start_8 .. :try_end_c} :catchall_10

    .line 235
    :try_start_c
    invoke-virtual {v1}, Ljava/io/ObjectInputStream;->close()V
    :try_end_f
    .catch Ljava/io/IOException; {:try_start_c .. :try_end_f} :catch_f

    :catch_f
    return-object p0

    :catchall_10
    move-exception p0

    move-object v0, v1

    goto :goto_33

    :catch_13
    move-exception p0

    move-object v0, v1

    goto :goto_1f

    :catch_16
    move-exception p0

    move-object v0, v1

    goto :goto_26

    :catch_19
    move-exception p0

    move-object v0, v1

    goto :goto_2d

    :catchall_1c
    move-exception p0

    goto :goto_33

    :catch_1e
    move-exception p0

    .line 231
    :goto_1f
    :try_start_1f
    new-instance v1, Lorg/apache/commons/lang3/SerializationException;

    invoke-direct {v1, p0}, Lorg/apache/commons/lang3/SerializationException;-><init>(Ljava/lang/Throwable;)V

    throw v1

    :catch_25
    move-exception p0

    .line 229
    :goto_26
    new-instance v1, Lorg/apache/commons/lang3/SerializationException;

    invoke-direct {v1, p0}, Lorg/apache/commons/lang3/SerializationException;-><init>(Ljava/lang/Throwable;)V

    throw v1

    :catch_2c
    move-exception p0

    .line 227
    :goto_2d
    new-instance v1, Lorg/apache/commons/lang3/SerializationException;

    invoke-direct {v1, p0}, Lorg/apache/commons/lang3/SerializationException;-><init>(Ljava/lang/Throwable;)V

    throw v1
    :try_end_33
    .catchall {:try_start_1f .. :try_end_33} :catchall_1c

    :goto_33
    if-eqz v0, :cond_38

    .line 235
    :try_start_35
    invoke-virtual {v0}, Ljava/io/ObjectInputStream;->close()V
    :try_end_38
    .catch Ljava/io/IOException; {:try_start_35 .. :try_end_38} :catch_38

    .line 239
    :catch_38
    :cond_38
    throw p0

    .line 216
    :cond_39
    new-instance p0, Ljava/lang/IllegalArgumentException;

    const-string v0, "The InputStream must not be null"

    invoke-direct {p0, v0}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V

    throw p0
.end method

.method public static deserialize([B)Ljava/lang/Object;
    .registers 2
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "<T:",
            "Ljava/lang/Object;",
            ">([B)TT;"
        }
    .end annotation

    if-eqz p0, :cond_c

    .line 267
    new-instance v0, Ljava/io/ByteArrayInputStream;

    invoke-direct {v0, p0}, Ljava/io/ByteArrayInputStream;-><init>([B)V

    invoke-static {v0}, Lorg/apache/commons/lang3/SerializationUtils;->deserialize(Ljava/io/InputStream;)Ljava/lang/Object;

    move-result-object p0

    return-object p0

    .line 265
    :cond_c
    new-instance p0, Ljava/lang/IllegalArgumentException;

    const-string v0, "The byte[] must not be null"

    invoke-direct {p0, v0}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V

    throw p0
.end method

.method public static roundtrip(Ljava/io/Serializable;)Ljava/io/Serializable;
    .registers 1
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "<T::",
            "Ljava/io/Serializable;",
            ">(TT;)TT;"
        }
    .end annotation

    .line 125
    invoke-static {p0}, Lorg/apache/commons/lang3/SerializationUtils;->serialize(Ljava/io/Serializable;)[B

    move-result-object p0

    invoke-static {p0}, Lorg/apache/commons/lang3/SerializationUtils;->deserialize([B)Ljava/lang/Object;

    move-result-object p0

    check-cast p0, Ljava/io/Serializable;

    return-object p0
.end method

.method public static serialize(Ljava/io/Serializable;Ljava/io/OutputStream;)V
    .registers 4

    if-eqz p1, :cond_24

    const/4 v0, 0x0

    .line 152
    :try_start_3
    new-instance v1, Ljava/io/ObjectOutputStream;

    invoke-direct {v1, p1}, Ljava/io/ObjectOutputStream;-><init>(Ljava/io/OutputStream;)V
    :try_end_8
    .catch Ljava/io/IOException; {:try_start_3 .. :try_end_8} :catch_17
    .catchall {:try_start_3 .. :try_end_8} :catchall_15

    .line 153
    :try_start_8
    invoke-virtual {v1, p0}, Ljava/io/ObjectOutputStream;->writeObject(Ljava/lang/Object;)V
    :try_end_b
    .catch Ljava/io/IOException; {:try_start_8 .. :try_end_b} :catch_12
    .catchall {:try_start_8 .. :try_end_b} :catchall_f

    .line 160
    :try_start_b
    invoke-virtual {v1}, Ljava/io/ObjectOutputStream;->close()V
    :try_end_e
    .catch Ljava/io/IOException; {:try_start_b .. :try_end_e} :catch_e

    :catch_e
    return-void

    :catchall_f
    move-exception p0

    move-object v0, v1

    goto :goto_1e

    :catch_12
    move-exception p0

    move-object v0, v1

    goto :goto_18

    :catchall_15
    move-exception p0

    goto :goto_1e

    :catch_17
    move-exception p0

    .line 156
    :goto_18
    :try_start_18
    new-instance p1, Lorg/apache/commons/lang3/SerializationException;

    invoke-direct {p1, p0}, Lorg/apache/commons/lang3/SerializationException;-><init>(Ljava/lang/Throwable;)V

    throw p1
    :try_end_1e
    .catchall {:try_start_18 .. :try_end_1e} :catchall_15

    :goto_1e
    if-eqz v0, :cond_23

    .line 160
    :try_start_20
    invoke-virtual {v0}, Ljava/io/ObjectOutputStream;->close()V
    :try_end_23
    .catch Ljava/io/IOException; {:try_start_20 .. :try_end_23} :catch_23

    .line 164
    :catch_23
    :cond_23
    throw p0

    .line 147
    :cond_24
    new-instance p0, Ljava/lang/IllegalArgumentException;

    const-string p1, "The OutputStream must not be null"

    invoke-direct {p0, p1}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V

    throw p0
.end method

.method public static serialize(Ljava/io/Serializable;)[B
    .registers 3

    .line 177
    new-instance v0, Ljava/io/ByteArrayOutputStream;

    const/16 v1, 0x200

    invoke-direct {v0, v1}, Ljava/io/ByteArrayOutputStream;-><init>(I)V

    .line 178
    invoke-static {p0, v0}, Lorg/apache/commons/lang3/SerializationUtils;->serialize(Ljava/io/Serializable;Ljava/io/OutputStream;)V

    .line 179
    invoke-virtual {v0}, Ljava/io/ByteArrayOutputStream;->toByteArray()[B

    move-result-object p0

    return-object p0
.end method