public Object newInstance(final String type, ObjectInput in)
        throws IOException, ClassNotFoundException, InstantiationException,
        InvocationTargetException, IllegalAccessException {

        Constructor<?> constructor = constructors.get(type);

        if (constructor == null) {
            Class<?> clazz = ClassUtil.forName(type);
            constructor = findDefaultConstructor(clazz);
            Constructor<?> previousConstructor = constructors.putIfAbsent(type, constructor);
            if (previousConstructor != null)
                constructor = previousConstructor; // Should be the same instance, anyway...
        }

        return constructor.newInstance(ZERO_ARGS);
    }