ClassLibrary { public static <T> T newInstance(Class<T> theClass) { try { return theClass.newInstance(); } catch (Exception e) { e.printStackTrace(); throw new RuntimeException("Colud not instantiate " + theClass, e); } }  static T newInstance(Class<T> theClass); static Object invoke(Method method, Object receiver, Object... arguments); static Object invokeTrespassing(Method method, Object receiver, Object... arguments); static boolean hasMethod(Class<?> aClass, String methodName, List<? extends Class<?>> parameterTypes); static Method method(String methodName, Class<?> aClass, Class<?>... argumentClasses); static boolean isInstanceOf(Class<?> aClass, Object object); static boolean isSuperclassOf(Class<?> subclass, Class<?> thisClass); static boolean isSubclassOf(Class<?> superclass, Class<?> thisClass); static boolean isAbstract(Class<?> aClass); static boolean isGreaterThan(T compared, T inRelationTo); static boolean isLessThan(T compared, T inRelationTo); @SuppressWarnings("unchecked") static int comparison(T one, T other);  }
@Test public void createInstanceWithReflection() { Class<?> objectClass = ClassLibraryTest.class; Object object = newInstance(objectClass); assertEquals(objectClass, object.getClass()); }