/** * Deserializes the serialized object, using the specified * <code>ClassLoader</code> to load classes as necessary. * @param loader The <code>ClassLoader</code> to use to load classes. * @return The deserialized object. * @throws ClassNotFoundException If a required class could not be found * during deserialization. */ @SuppressWarnings("unchecked") public T deserialize(ClassLoader loader) throws ClassNotFoundException { try { ByteArrayInputStream byteStream = new ByteArrayInputStream(data); GZIPInputStream gzipStream = new GZIPInputStream(byteStream); try { ObjectInputStream objectStream = new AlternateClassLoaderObjectInputStream( gzipStream, loader); object = (T) objectStream.readObject(); return object; } finally { gzipStream.close(); } } catch (IOException e) { throw new UnexpectedException(e); } }