SerializationUtils.java 11.9 KB
package org.apache.commons.lang3;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectInputStream;
import java.io.ObjectStreamClass;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

public class SerializationUtils
{
  /* Error */
  public static <T extends Serializable> T clone(T paramT)
  {
    // Byte code:
    //   0: aload_0
    //   1: ifnonnull +5 -> 6
    //   4: aconst_null
    //   5: areturn
    //   6: new 20	java/io/ByteArrayInputStream
    //   9: dup
    //   10: aload_0
    //   11: invokestatic 24	org/apache/commons/lang3/SerializationUtils:serialize	(Ljava/io/Serializable;)[B
    //   14: invokespecial 27	java/io/ByteArrayInputStream:<init>	([B)V
    //   17: astore_1
    //   18: new 6	org/apache/commons/lang3/SerializationUtils$a
    //   21: dup
    //   22: aload_1
    //   23: aload_0
    //   24: invokevirtual 31	java/lang/Object:getClass	()Ljava/lang/Class;
    //   27: invokevirtual 37	java/lang/Class:getClassLoader	()Ljava/lang/ClassLoader;
    //   30: invokespecial 40	org/apache/commons/lang3/SerializationUtils$a:<init>	(Ljava/io/InputStream;Ljava/lang/ClassLoader;)V
    //   33: astore_1
    //   34: aload_1
    //   35: astore_0
    //   36: aload_1
    //   37: invokevirtual 44	org/apache/commons/lang3/SerializationUtils$a:readObject	()Ljava/lang/Object;
    //   40: checkcast 46	java/io/Serializable
    //   43: astore_2
    //   44: aload_1
    //   45: invokevirtual 49	org/apache/commons/lang3/SerializationUtils$a:close	()V
    //   48: aload_2
    //   49: areturn
    //   50: astore_0
    //   51: new 51	org/apache/commons/lang3/SerializationException
    //   54: dup
    //   55: ldc 53
    //   57: aload_0
    //   58: invokespecial 56	org/apache/commons/lang3/SerializationException:<init>	(Ljava/lang/String;Ljava/lang/Throwable;)V
    //   61: athrow
    //   62: astore_2
    //   63: aconst_null
    //   64: astore_0
    //   65: new 51	org/apache/commons/lang3/SerializationException
    //   68: dup
    //   69: ldc 58
    //   71: aload_2
    //   72: invokespecial 56	org/apache/commons/lang3/SerializationException:<init>	(Ljava/lang/String;Ljava/lang/Throwable;)V
    //   75: athrow
    //   76: astore_2
    //   77: aload_0
    //   78: astore_1
    //   79: aload_2
    //   80: astore_0
    //   81: aload_1
    //   82: ifnull +7 -> 89
    //   85: aload_1
    //   86: invokevirtual 49	org/apache/commons/lang3/SerializationUtils$a:close	()V
    //   89: aload_0
    //   90: athrow
    //   91: astore_2
    //   92: aconst_null
    //   93: astore_0
    //   94: new 51	org/apache/commons/lang3/SerializationException
    //   97: dup
    //   98: ldc 60
    //   100: aload_2
    //   101: invokespecial 56	org/apache/commons/lang3/SerializationException:<init>	(Ljava/lang/String;Ljava/lang/Throwable;)V
    //   104: athrow
    //   105: astore_0
    //   106: new 51	org/apache/commons/lang3/SerializationException
    //   109: dup
    //   110: ldc 53
    //   112: aload_0
    //   113: invokespecial 56	org/apache/commons/lang3/SerializationException:<init>	(Ljava/lang/String;Ljava/lang/Throwable;)V
    //   116: athrow
    //   117: astore_0
    //   118: aconst_null
    //   119: astore_1
    //   120: goto -39 -> 81
    //   123: astore_2
    //   124: aload_1
    //   125: astore_0
    //   126: goto -32 -> 94
    //   129: astore_2
    //   130: aload_1
    //   131: astore_0
    //   132: goto -67 -> 65
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	135	0	paramT	T
    //   17	114	1	localObject1	Object
    //   43	6	2	localSerializable	Serializable
    //   62	10	2	localClassNotFoundException1	ClassNotFoundException
    //   76	4	2	localObject2	Object
    //   91	10	2	localIOException1	IOException
    //   123	1	2	localIOException2	IOException
    //   129	1	2	localClassNotFoundException2	ClassNotFoundException
    // Exception table:
    //   from	to	target	type
    //   44	48	50	java/io/IOException
    //   18	34	62	java/lang/ClassNotFoundException
    //   36	44	76	finally
    //   65	76	76	finally
    //   94	105	76	finally
    //   18	34	91	java/io/IOException
    //   85	89	105	java/io/IOException
    //   18	34	117	finally
    //   36	44	123	java/io/IOException
    //   36	44	129	java/lang/ClassNotFoundException
  }
  
  /* Error */
  public static <T> T deserialize(InputStream paramInputStream)
  {
    // Byte code:
    //   0: aload_0
    //   1: ifnonnull +13 -> 14
    //   4: new 66	java/lang/IllegalArgumentException
    //   7: dup
    //   8: ldc 68
    //   10: invokespecial 71	java/lang/IllegalArgumentException:<init>	(Ljava/lang/String;)V
    //   13: athrow
    //   14: aconst_null
    //   15: astore_1
    //   16: aconst_null
    //   17: astore_2
    //   18: new 73	java/io/ObjectInputStream
    //   21: dup
    //   22: aload_0
    //   23: invokespecial 76	java/io/ObjectInputStream:<init>	(Ljava/io/InputStream;)V
    //   26: astore_0
    //   27: aload_0
    //   28: astore_1
    //   29: aload_0
    //   30: invokevirtual 77	java/io/ObjectInputStream:readObject	()Ljava/lang/Object;
    //   33: astore_2
    //   34: aload_0
    //   35: invokevirtual 78	java/io/ObjectInputStream:close	()V
    //   38: aload_2
    //   39: areturn
    //   40: astore_2
    //   41: aconst_null
    //   42: astore_0
    //   43: aload_0
    //   44: astore_1
    //   45: new 51	org/apache/commons/lang3/SerializationException
    //   48: dup
    //   49: aload_2
    //   50: invokespecial 81	org/apache/commons/lang3/SerializationException:<init>	(Ljava/lang/Throwable;)V
    //   53: athrow
    //   54: astore_0
    //   55: aload_1
    //   56: ifnull +7 -> 63
    //   59: aload_1
    //   60: invokevirtual 78	java/io/ObjectInputStream:close	()V
    //   63: aload_0
    //   64: athrow
    //   65: astore_0
    //   66: aload_2
    //   67: astore_1
    //   68: new 51	org/apache/commons/lang3/SerializationException
    //   71: dup
    //   72: aload_0
    //   73: invokespecial 81	org/apache/commons/lang3/SerializationException:<init>	(Ljava/lang/Throwable;)V
    //   76: athrow
    //   77: astore_0
    //   78: goto -23 -> 55
    //   81: astore_0
    //   82: aload_2
    //   83: areturn
    //   84: astore_1
    //   85: goto -22 -> 63
    //   88: astore_2
    //   89: aload_0
    //   90: astore_1
    //   91: aload_2
    //   92: astore_0
    //   93: goto -25 -> 68
    //   96: astore_2
    //   97: goto -54 -> 43
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	100	0	paramInputStream	InputStream
    //   15	53	1	localObject1	Object
    //   84	1	1	localIOException1	IOException
    //   90	1	1	localInputStream	InputStream
    //   17	22	2	localObject2	Object
    //   40	43	2	localClassNotFoundException1	ClassNotFoundException
    //   88	4	2	localIOException2	IOException
    //   96	1	2	localClassNotFoundException2	ClassNotFoundException
    // Exception table:
    //   from	to	target	type
    //   18	27	40	java/lang/ClassNotFoundException
    //   29	34	54	finally
    //   45	54	54	finally
    //   18	27	65	java/io/IOException
    //   18	27	77	finally
    //   68	77	77	finally
    //   34	38	81	java/io/IOException
    //   59	63	84	java/io/IOException
    //   29	34	88	java/io/IOException
    //   29	34	96	java/lang/ClassNotFoundException
  }
  
  public static <T> T deserialize(byte[] paramArrayOfByte)
  {
    if (paramArrayOfByte == null) {
      throw new IllegalArgumentException("The byte[] must not be null");
    }
    return (T)deserialize(new ByteArrayInputStream(paramArrayOfByte));
  }
  
  public static <T extends Serializable> T roundtrip(T paramT)
  {
    return (Serializable)deserialize(serialize(paramT));
  }
  
  /* Error */
  public static void serialize(Serializable paramSerializable, java.io.OutputStream paramOutputStream)
  {
    // Byte code:
    //   0: aload_1
    //   1: ifnonnull +13 -> 14
    //   4: new 66	java/lang/IllegalArgumentException
    //   7: dup
    //   8: ldc 94
    //   10: invokespecial 71	java/lang/IllegalArgumentException:<init>	(Ljava/lang/String;)V
    //   13: athrow
    //   14: new 96	java/io/ObjectOutputStream
    //   17: dup
    //   18: aload_1
    //   19: invokespecial 99	java/io/ObjectOutputStream:<init>	(Ljava/io/OutputStream;)V
    //   22: astore_2
    //   23: aload_2
    //   24: astore_1
    //   25: aload_2
    //   26: aload_0
    //   27: invokevirtual 103	java/io/ObjectOutputStream:writeObject	(Ljava/lang/Object;)V
    //   30: aload_2
    //   31: invokevirtual 104	java/io/ObjectOutputStream:close	()V
    //   34: return
    //   35: astore_0
    //   36: aconst_null
    //   37: astore_1
    //   38: new 51	org/apache/commons/lang3/SerializationException
    //   41: dup
    //   42: aload_0
    //   43: invokespecial 81	org/apache/commons/lang3/SerializationException:<init>	(Ljava/lang/Throwable;)V
    //   46: athrow
    //   47: astore_0
    //   48: aload_1
    //   49: ifnull +7 -> 56
    //   52: aload_1
    //   53: invokevirtual 104	java/io/ObjectOutputStream:close	()V
    //   56: aload_0
    //   57: athrow
    //   58: astore_0
    //   59: return
    //   60: astore_1
    //   61: goto -5 -> 56
    //   64: astore_0
    //   65: aconst_null
    //   66: astore_1
    //   67: goto -19 -> 48
    //   70: astore_0
    //   71: aload_2
    //   72: astore_1
    //   73: goto -35 -> 38
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	76	0	paramSerializable	Serializable
    //   0	76	1	paramOutputStream	java.io.OutputStream
    //   22	50	2	localObjectOutputStream	java.io.ObjectOutputStream
    // Exception table:
    //   from	to	target	type
    //   14	23	35	java/io/IOException
    //   25	30	47	finally
    //   38	47	47	finally
    //   30	34	58	java/io/IOException
    //   52	56	60	java/io/IOException
    //   14	23	64	finally
    //   25	30	70	java/io/IOException
  }
  
  public static byte[] serialize(Serializable paramSerializable)
  {
    ByteArrayOutputStream localByteArrayOutputStream = new ByteArrayOutputStream(512);
    serialize(paramSerializable, localByteArrayOutputStream);
    return localByteArrayOutputStream.toByteArray();
  }
  
  static final class a
    extends ObjectInputStream
  {
    private static final Map<String, Class<?>> a;
    private final ClassLoader b;
    
    static
    {
      HashMap localHashMap = new HashMap();
      a = localHashMap;
      localHashMap.put("byte", Byte.TYPE);
      a.put("short", Short.TYPE);
      a.put("int", Integer.TYPE);
      a.put("long", Long.TYPE);
      a.put("float", Float.TYPE);
      a.put("double", Double.TYPE);
      a.put("boolean", Boolean.TYPE);
      a.put("char", Character.TYPE);
      a.put("void", Void.TYPE);
    }
    
    public a(InputStream paramInputStream, ClassLoader paramClassLoader)
      throws IOException
    {
      super();
      this.b = paramClassLoader;
    }
    
    protected final Class<?> resolveClass(ObjectStreamClass paramObjectStreamClass)
      throws IOException, ClassNotFoundException
    {
      Object localObject = paramObjectStreamClass.getName();
      try
      {
        paramObjectStreamClass = Class.forName((String)localObject, false, this.b);
        return paramObjectStreamClass;
      }
      catch (ClassNotFoundException paramObjectStreamClass)
      {
        do
        {
          try
          {
            paramObjectStreamClass = Class.forName((String)localObject, false, Thread.currentThread().getContextClassLoader());
            return paramObjectStreamClass;
          }
          catch (ClassNotFoundException localClassNotFoundException)
          {
            localObject = (Class)a.get(localObject);
            paramObjectStreamClass = (ObjectStreamClass)localObject;
          }
        } while (localObject != null);
        throw localClassNotFoundException;
      }
    }
  }
}


/* Location:              /home/merong/decompile/hackery-dex2jar.jar!/org/apache/commons/lang3/SerializationUtils.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       0.7.1
 */