public static <T> Optional<T> tryToCreate(Class<T> clazz, Properties properties, List<Object> instances, Set<Class<?>> allInjectableTypes, InjectorProxy injectorProxy)
        throws InstantiationException {
        try {
            final Optional<Constructor<T>> oConstr = findConstructor(clazz, instances, allInjectableTypes);

            if (!oConstr.isPresent()) {
                return Optional.empty();
            }

            final Constructor<T> constr = oConstr.get();

            final Parameter[] params = constr.getParameters();
            final Object[] args = new Object[params.length];
            for (int i = 0; i < params.length; i++) {
                final Parameter param = params[i];
                final Config config = param.getAnnotation(Config.class);
                final Object arg;
                if (config != null) {
                    arg = configField(clazz, properties, param, config);
                } else {
                    arg = notConfigField(clazz, instances, allInjectableTypes, param);
                    if (arg == null) {
                        return Optional.empty();
                    }
                }
                args[i] = arg;
            }

            final T instance = injectorProxy.newInstance(constr, args);
            configureParams(instance, properties, injectorProxy);

            return Optional.of(instance);

        } catch (final IllegalAccessException
            | IllegalArgumentException
            | InvocationTargetException ex) {

            throw new InjectorException(String.format(
                "Unable to create class '%s'.", clazz.getName()
            ), ex);
        }
    }
Some common utility methods for analyzing classes with reflection.

@author Emil Forslund
@since 1.0.0
common-parent/injector/src/main/java/com/speedment/common/injector/internal/util/ReflectionUtil.java