@Test(expected=NoSuchMethodException.class) public void shouldFailInstantiateNotAccessibleClassWithUnknownConstructors() throws InvocationTargetException, NoSuchMethodException, InstantiationException, IllegalAccessException { ComponentFactory.instantiate(NotAccessiblePublicClassWithUninstantiable.class, mockCRestConfig); }
public static <T> T instantiate(Class<T> clazz, CRestConfig crestConfig) throws InvocationTargetException, IllegalAccessException, InstantiationException, NoSuchMethodException { try { return accessible(clazz.getDeclaredConstructor(CRestConfig.class)).newInstance(crestConfig); } catch (NoSuchMethodException e) { return accessible(clazz.getDeclaredConstructor()).newInstance(); } }
ComponentFactory { public static <T> T instantiate(Class<T> clazz, CRestConfig crestConfig) throws InvocationTargetException, IllegalAccessException, InstantiationException, NoSuchMethodException { try { return accessible(clazz.getDeclaredConstructor(CRestConfig.class)).newInstance(crestConfig); } catch (NoSuchMethodException e) { return accessible(clazz.getDeclaredConstructor()).newInstance(); } } }
ComponentFactory { public static <T> T instantiate(Class<T> clazz, CRestConfig crestConfig) throws InvocationTargetException, IllegalAccessException, InstantiationException, NoSuchMethodException { try { return accessible(clazz.getDeclaredConstructor(CRestConfig.class)).newInstance(crestConfig); } catch (NoSuchMethodException e) { return accessible(clazz.getDeclaredConstructor()).newInstance(); } } private  ComponentFactory(); }
ComponentFactory { public static <T> T instantiate(Class<T> clazz, CRestConfig crestConfig) throws InvocationTargetException, IllegalAccessException, InstantiationException, NoSuchMethodException { try { return accessible(clazz.getDeclaredConstructor(CRestConfig.class)).newInstance(crestConfig); } catch (NoSuchMethodException e) { return accessible(clazz.getDeclaredConstructor()).newInstance(); } } private  ComponentFactory(); static T instantiate(Class<T> clazz, CRestConfig crestConfig); }
ComponentFactory { public static <T> T instantiate(Class<T> clazz, CRestConfig crestConfig) throws InvocationTargetException, IllegalAccessException, InstantiationException, NoSuchMethodException { try { return accessible(clazz.getDeclaredConstructor(CRestConfig.class)).newInstance(crestConfig); } catch (NoSuchMethodException e) { return accessible(clazz.getDeclaredConstructor()).newInstance(); } } private  ComponentFactory(); static T instantiate(Class<T> clazz, CRestConfig crestConfig);  }