private final Constructor mungedConstructor;
public SunReflectionFactorySerializationInstantiator(final Class type) {
final Class nonSerializableAncestor = SerializationInstantiatorHelper.getNonSerializableSuperClass( type );
final ReflectionFactory reflectionFactory = ReflectionFactory.getReflectionFactory();
Constructor nonSerializableAncestorConstructor;
try {
nonSerializableAncestorConstructor = nonSerializableAncestor.getConstructor( (Class[]) null );
} catch ( final NoSuchMethodException e ) {
/**
* @todo (Henri) I think we should throw a NotSerializableException just to put the same
* message a ObjectInputStream. Otherwise, the user won't know if the null returned
* if a "Not serializable", a "No default constructor on ancestor" or a "Exception in
* constructor"
*/
throw new ObjenesisException( new NotSerializableException( type + " has no suitable superclass constructor" ) );
}
this.mungedConstructor = reflectionFactory.newConstructorForSerialization( type,
nonSerializableAncestorConstructor );
this.mungedConstructor.setAccessible( true );
}