try {
defaultConstructor = type.getDeclaredConstructor((Class[]) null);
if (!defaultConstructor.isAccessible()) {
defaultConstructor.setAccessible(true);
}
final Externalizable externalizable = (Externalizable) defaultConstructor.newInstance((Object[]) null);
CustomObjectInputStream.StreamCallback callback = new CustomObjectInputStream.StreamCallback() {
public Object readFromStream() {
reader.moveDown();
Class type = HierarchicalStreams.readClassType(reader, mapper);
Object streamItem = context.convertAnother(externalizable, type);
reader.moveUp();
return streamItem;
}
public Map readFieldsFromStream() {
throw new UnsupportedOperationException();
}
public void defaultReadObject() {
throw new UnsupportedOperationException();
}
public void registerValidation(ObjectInputValidation validation, int priority) throws NotActiveException {
throw new NotActiveException("stream inactive");
}
public void close() {
throw new UnsupportedOperationException("Objects are not allowed to call ObjectInput.close() from readExternal()");
}
};
CustomObjectInputStream objectInput = CustomObjectInputStream.getInstance(context, callback, classLoader);
externalizable.readExternal(objectInput);
objectInput.popCallback();
return externalizable;
} catch (NoSuchMethodException e) {
throw new ConversionException("Cannot construct " + type.getClass() + ", missing default constructor", e);
} catch (InvocationTargetException e) {