if (expectedType != null) {
SerializabilityUtil.resolveTypes(expectedType, resolvedTypes);
expectedParameterTypes = SerializabilityUtil.findExpectedParameterTypes(
instanceClass, expectedType, resolvedTypes);
if (expectedParameterTypes == null) {
throw new SerializedTypeViolationException("Attempt to deserialize an object of type "
+ instanceClass.toString() + " when an object of type "
+ SerializabilityUtil.findActualType(expectedType, resolvedTypes).toString()
+ " is expected");
}