ReflectionUtils { @Api(2.0) @NonNull public static <T> T build(@NonNull Constructor<T> constructor, @Nullable Object... data) { try { return constructor.newInstance(data); } catch (InstantiationException e) { throw new HaloReflectionException("It is not possible to create an instance of class " + constructor.getDeclaringClass().getCanonicalName() + ".", e); } catch (IllegalAccessException e) { throw new HaloReflectionException("The constructor is not accessible for class " + constructor.getDeclaringClass().getCanonicalName() + ".", e); } catch (InvocationTargetException e) { throw new HaloReflectionException("Exception thrown by invoked constructor for class " + constructor.getDeclaringClass().getCanonicalName() + ".", e); } catch (IllegalArgumentException e) { throw new HaloReflectionException("Exception thrown for invalid parameters in class " + constructor.getDeclaringClass().getCanonicalName() + ".", e); } } private  ReflectionUtils(); @Api(2.0) @Nullable static Class<?> toClass(@Nullable String name); @Api(2.0) @Nullable static T newInstance(@NonNull Class<T> clazz); @Api(2.0) @NonNull static Constructor<T> getConstructor(@NonNull Class<T> constructedClass, @NonNull Class<D> innerConstructorClass); @Api(2.0) @NonNull static T build(@NonNull Constructor<T> constructor, @Nullable Object... data); @Api(2.0) @NonNull static String classNameToInnerFilter(@NonNull String className); @Api(2.0) @NonNull static Field[] getFields(@NonNull Class clazz, boolean bringParents); @Api(2.0) @NonNull static T valueOf(Field field, Object reference, Class<T> clazz);  }
@Test public void buildTest() { PublicConstructorParam instance = ReflectionUtils.build(ReflectionUtils.getConstructor(PublicConstructorParam.class, PublicConstructorNoParam.class), new PublicConstructorNoParam()); Assert.assertNotNull(instance); }