private Object newInstance()

in geronimo-openapi-impl/src/main/java/org/apache/geronimo/microprofile/openapi/cdi/GeronimoOpenAPIExtension.java [194:209]


    private Object newInstance(final CDI<Object> current, final String value) {
        try {
            final Class<?> clazz = Thread.currentThread().getContextClassLoader().loadClass(value.trim());
            try {
                final Instance<?> instance = current.select(clazz);
                if (!instance.isAmbiguous() && !instance.isUnsatisfied()) { // isResolvable is not always there
                    return instance.get();
                }
            } catch (final RuntimeException e) {
                // let do " new"
            }
            return clazz.getConstructor().newInstance();
        } catch (final Exception e) {
            throw new IllegalArgumentException("Can't load " + value, e);
        }
    }