public static <T> T newInstance(String className, ClassLoader loader) {
        try {
            return ((Class<T>) Class.forName(className, true, loader)).getDeclaredConstructor().newInstance();
        } catch (ClassNotFoundException | InstantiationException | IllegalAccessException |
                 NoSuchMethodException | InvocationTargetException e) {
            throw new RuntimeException(e);
        }
    }
Loads a class and instantiates it

@param className service class name
@param loader    class loader
@param <T>       service type
@return instance of service
tika-core/src/main/java/org/apache/tika/utils/ServiceLoaderUtils.java