private T tryConstructor(Constructor<T> constructor, Mapping config, ConfigurationContext context)
            throws ConfiguratorException {
        final Parameter[] parameters = constructor.getParameters();
        final String[] names = ClassDescriptor.loadParameterNames(constructor);
        Object[] args = new Object[names.length];

        if (parameters.length > 0) {
            // Many jenkins components haven't been migrated to @DataBoundSetter vs @NotNull constructor parameters
            // as a result it might be valid to reference a describable without parameters

            for (int i = 0; i < names.length; i++) {
                final CNode value = config.get(names[i]);
                final Class t = parameters[i].getType();

                Class<?> clazz = constructor.getDeclaringClass();
                if (value == null
                        && (parameters[i].isAnnotationPresent(Nonnull.class)
                                || constructor.isAnnotationPresent(ParametersAreNonnullByDefault.class)
                                || clazz.isAnnotationPresent(ParametersAreNonnullByDefault.class)
                                || clazz.getPackage().isAnnotationPresent(ParametersAreNonnullByDefault.class)
                                        && !parameters[i].isAnnotationPresent(CheckForNull.class))) {

                    if (Set.class.isAssignableFrom(t)) {
                        LOGGER.log(
                                Level.FINER,
                                "The parameter to be set is @Nonnull but is not present; "
                                        + "setting equal to empty set.");
                        args[i] = Collections.emptySet();
                    } else if (List.class.isAssignableFrom(t)) {
                        LOGGER.log(
                                Level.FINER,
                                "The parameter to be set is @Nonnull but is not present; "
                                        + "setting equal to empty list.");
                        args[i] = Collections.emptyList();
                    } else {
                        throw new ConfiguratorException(names[i] + " is required to configure " + target);
                    }
                    continue;
                }

                if (value != null) {
                    if (Collection.class.isAssignableFrom(t)) {
                        final Type pt = parameters[i].getParameterizedType();
                        final Configurator lookup = context.lookupOrFail(pt);

                        final Collection<Object> collection;

                        if (Set.class.isAssignableFrom(t)) {
                            collection = new HashSet<>();
                        } else {
                            collection = new ArrayList<>();
                        }

                        for (CNode o : value.asSequence()) {
                            collection.add(lookup.configure(o, context));
                        }
                        args[i] = collection;

                    } else {
                        final Type pt = parameters[i].getParameterizedType();
                        final Type k = pt != null ? pt : t;
                        final Configurator configurator = context.lookupOrFail(k);
                        args[i] = configurator.configure(value, context);
                    }
                    if (LOGGER.isLoggable(Level.FINE)) {
                        LOGGER.log(Level.FINE, "Setting {0}.{1} = {2}", new Object[] {
                            target,
                            names[i],
                            t == Secret.class || Attribute.calculateIfSecret(target, names[i]) ? "****" : value
                        });
                    }
                } else if (t.isPrimitive()) {
                    args[i] = defaultPrimitiveValue(t);
                }
            }
        }

        final T object;
        try {
            object = constructor.newInstance(args);
        } catch (IllegalArgumentException
                | InstantiationException
                | InvocationTargetException
                | IllegalAccessException ex) {
            List<String> argumentTypes = new ArrayList<>(args.length);
            for (Object arg : args) {
                argumentTypes.add(arg != null ? arg.getClass().getName() : "null");
            }
            List<String> parameterTypes = new ArrayList<>(parameters.length);
            for (Parameter parameter : parameters) {
                parameterTypes.add(parameter.getParameterizedType().getTypeName());
            }
            List<String> expectedParamList = new ArrayList<>(parameters.length);
            for (int i = 0; i < parameters.length; i++) {
                expectedParamList.add(names[i] + " " + parameterTypes.get(i));
            }
            throw new ConfiguratorException(
                    this,
                    "Failed to construct instance of " + target + ".\n Constructor: "
                            + constructor + ".\n Arguments: "
                            + argumentTypes + ".\n Expected Parameters: "
                            + String.join(", ", expectedParamList),
                    ex);
        }

        // constructor was successful, so let's removed configuration elements we have consumed doing so.
        for (String name : names) {
            config.remove(name);
        }

        return object;
    }
Build a fresh new component based on provided configuration and {@link org.kohsuke.stapler.DataBoundConstructor}
plugin/src/main/java/io/jenkins/plugins/casc/impl/configurators/DataBoundConfigurator.java