ReflectionUtils { public static <T> T newInstance(Class<T> type) throws ReflectiveOperationException { Constructor<T> constructor = type.getDeclaredConstructor(new Class<?>[]{}); constructor.setAccessible(true); return constructor.newInstance(new Object[]{}); }  static T newInstance(Class<T> type); static Class<T> getActualType(Class<?> type); @SuppressWarnings("unchecked") static Class<T> getActualType(Class<?> type, int index);  }
@Test public void newInstance() throws Exception { A a = ReflectionUtils.newInstance(A.class); assertNotNull(a); B b = ReflectionUtils.newInstance(B.class); assertNotNull(b); C c = ReflectionUtils.newInstance(C.class); assertNotNull(c); b.setB(a); assertEquals(b.getB(), a); }