ReflectionUtil { public static <T> T invokeConstructor(final Class<T> cls, Object... args) { try { return ConstructorUtils.invokeConstructor(cls, args); } catch (Exception e) { throw ExceptionUtil.unwrapAndUnchecked(e); } }  static Method getSetterMethod(Class<?> clazz, String propertyName, Class<?> parameterType); static Method getGetterMethod(Class<?> clazz, String propertyName); static Method getMethod(final Class<?> clazz, final String methodName, Class<?>... parameterTypes); static Method getAccessibleMethodByName(final Class clazz, final String methodName); static Field getField(final Class clazz, final String fieldName); static T invokeGetter(Object obj, String propertyName); static void invokeSetter(Object obj, String propertyName, Object value); static T getFieldValue(final Object obj, final String fieldName); static T getFieldValue(final Object obj, final Field field); static void setFieldValue(final Object obj, final String fieldName, final Object value); static void setField(final Object obj, Field field, final Object value); static T getProperty(Object obj, String propertyName); static void setProperty(Object obj, String propertyName, final Object value); static T invokeMethod(Object obj, String methodName, Object... args); static T invokeMethod(final Object obj, final String methodName, final Object[] args,
			final Class<?>[] parameterTypes); static T invokeMethodByName(final Object obj, final String methodName, final Object[] args); static T invokeMethod(final Object obj, Method method, Object... args); static T invokeConstructor(final Class<T> cls, Object... args); static void makeAccessible(Method method); static void makeAccessible(Field field); static RuntimeException convertReflectionExceptionToUnchecked(Exception e);  }
@Test public void invokeConstructor() { TestBean bean = ReflectionUtil.invokeConstructor(TestBean.class); assertThat(bean.getPublicField()).isEqualTo(2); TestBean3 bean3 = ReflectionUtil.invokeConstructor(TestBean3.class, 4); assertThat(bean3.getId()).isEqualTo(4); }