Object anObject = null;
try
{
anObject = input.readObject();
if ( !anObject.getClass().equals( expectedClass ) )
{
throw new ClassNotFoundException();
}
}
catch ( IOException exception )
{
throw new SeriousErrorException(
ERROR_CREATING_OBJECT_STREAM, exception );
}
catch ( ClassNotFoundException exception )
{
throw new SeriousErrorException(
ERROR_STREAM_NOT_COLLECTION, exception );
}
return anObject;