ReflectionUtils { @SuppressWarnings("unchecked") public static <T> T newInstance(Class<T> theClass, Configuration conf) { return newInstance(theClass, conf, EMPTY_ARRAY); }  static void setConf(Object theObject, Configuration conf); @SuppressWarnings("unchecked") static T newInstance(Class<T> theClass, Configuration conf); @SuppressWarnings("unchecked") static T newInstance(Class<T> theClass, Configuration conf,
      Class<?>[] argTypes, Object ... values); static void setContentionTracing(boolean val); synchronized static void printThreadInfo(PrintStream stream,
                                     String title); static void logThreadInfo(Log log,
                                   String title,
                                   long minInterval); static void logThreadInfo(Logger log,
                                   String title,
                                   long minInterval); @SuppressWarnings("unchecked") static Class<T> getClass(T o); @SuppressWarnings("unchecked") static T copy(Configuration conf, 
                                T src, T dst); @Deprecated static void cloneWritableInto(Writable dst, 
                                       Writable src); static List<Field> getDeclaredFieldsIncludingInherited(Class<?> clazz); static List<Method> getDeclaredMethodsIncludingInherited(Class<?> clazz);  }
@Test public void testNewInstanceForNonDefaultConstructor() { Object x = ReflectionUtils.newInstance( NoDefaultCtor.class, null, new Class[] {int.class}, 1); assertTrue(x instanceof NoDefaultCtor); }
@Test public void testNewInstanceForNonDefaultConstructorWithException() { try { ReflectionUtils.newInstance( NoDefaultCtor.class, null, new Class[]{int.class}, 1, 2); fail("Should have failed before this point"); } catch (IllegalArgumentException e) { GenericTestUtils.assertExceptionContains( "1 parameters are required but 2 arguments are provided", e); } try { ReflectionUtils.newInstance( NoDefaultCtor.class, null, new Class[]{int.class}); fail("Should have failed before this point"); } catch (IllegalArgumentException e) { GenericTestUtils.assertExceptionContains( "1 parameters are required but 0 arguments are provided", e); } }