public static Object readObject(DataInputStream input, ClassLoader loader)
            throws IOException, ClassNotFoundException {
        int n = input.readInt();
        byte[] data = new byte[n];
        input.readFully(data);

        ObjectInputStream deserializer =
                new ForkObjectInputStream(new ByteArrayInputStream(data), loader);
        return deserializer.readObject();
    }
Deserializes an object from the given stream. The serialized object
is expected to be preceded by a size integer, that is used for reading
the entire serialization into a memory before deserializing it.

@param input  input stream from which the serialized object is read
@param loader class loader to be used for loading referenced classes
@throws IOException            if the object could not be deserialized
@throws ClassNotFoundException if a referenced class is not found
tika-core/src/main/java/org/apache/tika/fork/ForkObjectInputStream.java