public static ObjectInputStream newObjectInputStream(final InputStream in) throws IOException {
        return new ObjectInputStream(in) {
            @Override
            protected Class<?> resolveClass(final ObjectStreamClass desc) throws ClassNotFoundException {
                return loadClass(desc.getName());
            }
        };
    }
Reads a Map of Serializable key and value pairs. This method will return
<tt>null</tt> if the Map written to the stream was <tt>null</tt>.

@param in the input stream.
@param map a Map of Serializable key and value pairs.
@param loader class loader to use to build elements inside of the serialized collection.
@throws IOException if an error occurs.
@return the number of elements added to the collection.
xmppserver/src/main/java/org/jivesoftware/util/cache/DefaultExternalizableUtil.java