@Test public void testResolveWithFaultyConstructor() { assertThatExceptionOfType(ConfigurationException.class) .isThrownBy(() -> ReflectionUtils.resolveClassOfType(OverridingClassWithoutConstructor.class.getName(), TestInterface.class, String.class)); }
public static <T> Class<? extends T> resolveClassOfType(String className, Class<T> wantedClass, Class<?>... parameterClasses) throws ConfigurationException { Class<? extends T> clazz; try { clazz = Class.forName(className).asSubclass(wantedClass); } catch (ClassCastException e) { throw new ConfigurationException("Class " + className + " not assignable from " + wantedClass, e); } catch (ClassNotFoundException e) { throw new ConfigurationException("Class " + className + " not found in classpath", e); } getConstructor(clazz, parameterClasses); return clazz; }
ReflectionUtils { public static <T> Class<? extends T> resolveClassOfType(String className, Class<T> wantedClass, Class<?>... parameterClasses) throws ConfigurationException { Class<? extends T> clazz; try { clazz = Class.forName(className).asSubclass(wantedClass); } catch (ClassCastException e) { throw new ConfigurationException("Class " + className + " not assignable from " + wantedClass, e); } catch (ClassNotFoundException e) { throw new ConfigurationException("Class " + className + " not found in classpath", e); } getConstructor(clazz, parameterClasses); return clazz; } }
ReflectionUtils { public static <T> Class<? extends T> resolveClassOfType(String className, Class<T> wantedClass, Class<?>... parameterClasses) throws ConfigurationException { Class<? extends T> clazz; try { clazz = Class.forName(className).asSubclass(wantedClass); } catch (ClassCastException e) { throw new ConfigurationException("Class " + className + " not assignable from " + wantedClass, e); } catch (ClassNotFoundException e) { throw new ConfigurationException("Class " + className + " not found in classpath", e); } getConstructor(clazz, parameterClasses); return clazz; } private  ReflectionUtils(); }
ReflectionUtils { public static <T> Class<? extends T> resolveClassOfType(String className, Class<T> wantedClass, Class<?>... parameterClasses) throws ConfigurationException { Class<? extends T> clazz; try { clazz = Class.forName(className).asSubclass(wantedClass); } catch (ClassCastException e) { throw new ConfigurationException("Class " + className + " not assignable from " + wantedClass, e); } catch (ClassNotFoundException e) { throw new ConfigurationException("Class " + className + " not found in classpath", e); } getConstructor(clazz, parameterClasses); return clazz; } private  ReflectionUtils(); static T construct(Class<? extends T> type, Object... parameters); static T construct(Class<? extends T> type, Class<?>[] parameterClasses, Object... parameters); static Class<? extends T> resolveClassOfType(String className, Class<T> wantedClass, Class<?>... parameterClasses); }
ReflectionUtils { public static <T> Class<? extends T> resolveClassOfType(String className, Class<T> wantedClass, Class<?>... parameterClasses) throws ConfigurationException { Class<? extends T> clazz; try { clazz = Class.forName(className).asSubclass(wantedClass); } catch (ClassCastException e) { throw new ConfigurationException("Class " + className + " not assignable from " + wantedClass, e); } catch (ClassNotFoundException e) { throw new ConfigurationException("Class " + className + " not found in classpath", e); } getConstructor(clazz, parameterClasses); return clazz; } private  ReflectionUtils(); static T construct(Class<? extends T> type, Object... parameters); static T construct(Class<? extends T> type, Class<?>[] parameterClasses, Object... parameters); static Class<? extends T> resolveClassOfType(String className, Class<T> wantedClass, Class<?>... parameterClasses);  }