ReflectionUtils { public static <T> T newInstance(ClassLoader classLoader, String name) { try { return ClassLoaderUtil.newInstance(classLoader, name); } catch (Exception e) { throw sneakyThrow(e); } } private  ReflectionUtils(); static T readStaticFieldOrNull(String classname, String fieldName); @Nonnull @SuppressFBWarnings(value = "RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE", justification = "False positive on try-with-resources as of JDK11") static Collection<Class<?>> nestedClassesOf(Class<?>... classes); @Nonnull @SuppressFBWarnings(value = "RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE", justification = "False positive on try-with-resources as of JDK11") static Resources resourcesOf(String... packages); static String toClassResourceId(String name); static Class<?> loadClass(ClassLoader classLoader, String name); static T newInstance(ClassLoader classLoader, String name);  }
@Test public void when_newInstance_then_returnsInstance() { OuterClass instance = ReflectionUtils.newInstance(OuterClass.class.getClassLoader(), OuterClass.class.getName()); assertThat(instance, notNullValue()); }