ReflectionUtil { 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); } } private  ReflectionUtil(); static Stream<Field> traverseFields(Class<?> clazz); static Stream<Method> traverseMethods(Class<?> clazz); static Stream<Class<?>> traverseAncestors(Class<?> clazz); static MissingArgumentStrategy missingArgumentStrategy(Executable executable); static Optional<T> tryToCreate(Class<T> clazz, Properties properties, List<Object> instances, Set<Class<?>> allInjectableTypes, InjectorProxy injectorProxy); @SuppressWarnings("unchecked") static String errorMsg(Class<T> c, List<Object> instances); static Optional<Object> parse(Type type, String serialized);  }
@Test void tryToCreate() throws InstantiationException { final Optional<Integer> actual = ReflectionUtil.tryToCreate(Integer.class, new Properties(), emptyList(), emptySet(), new MyInjectorProxy()); assertFalse(actual.isPresent()); }