SerializationUtil { public static Object jdkUnserial(final byte[] data) throws UtilException { Object result = null; if (data != null && data.length > 0) { ObjectInputStream in = null; try { in = new ObjectInputStream(new ByteArrayInputStream(data)); result = in.readObject(); } catch (Exception e) { throw new UtilException(e, ErrorCodeDef.JDK_UNSERIALIZE_ERROR, DataUtil.byte2HexStr(data)); } finally { if (in != null) { try { in.close(); } catch (IOException e) { throw new UtilException(ErrorCodeDef.JDK_UNSERIALIZE_ERROR); } } } } return result; }  @SuppressWarnings("unchecked") static byte[] serial(final T obj); static byte[] jdkSerial(final Object obj); @SuppressWarnings("unchecked") static T unserial(final Class<T> clazz, final byte[] data); static Object jdkUnserial(final byte[] data);  }
@Test public void jdkUnserial() { byte[] bs = DataUtil.hexStr2Byte("ACED00057372002E636F6D2E6862617365736F66742E6672616D65776F726B2E636F6D6D6F6E" + "2E7574696C732E6265616E2E4265616E0D3AF53B8EBFF7290200024900036167654C00046E61" + "6D657400124C6A6176612F6C616E672F537472696E673B78700000001274000B68656C6C6F20776F726C64"); Bean bean = (Bean) SerializationUtil.jdkUnserial(bs); Assert.equals(bean.getName(), "hello world", ErrorCodeDef.SYSTEM_ERROR_10001); }