static <T> Map<ClassLoader, Set<T>> loadExtensionInstances(
            ClassLoader classLoader, LinkedHashSet<String> instanceClassNames, Class<T> superType,
            String foundMsgHead, String failLoadMsgHead
    ) {
        Map<ClassLoader, Set<T>> ret = new HashMap<>();

        for (final String className : instanceClassNames) {
            try {
                final Class<?> clazz = classLoader.loadClass(className);
                if (!superType.isAssignableFrom(clazz)) {
                    final String msg = foundMsgHead + className
                            + " from classloader " + classLoader
                            + " at location " + getLocationUrlOfClass(clazz)
                            + ", but NOT subtype of " + superType.getName() + ", ignored!";
                    logger.error(msg);
                    continue;
                }

                Object instance = clazz.getDeclaredConstructor().newInstance();

                final ClassLoader actualClassLoader = instance.getClass().getClassLoader();
                Set<T> set = ret.computeIfAbsent(actualClassLoader, k -> new HashSet<>());
                set.add(superType.cast(instance));

                final String msg = foundMsgHead + className
                        + ", and loaded from classloader " + classLoader
                        + " at location " + getLocationUrlOfClass(clazz);
                logger.info(msg);
            } catch (ClassNotFoundException e) {
                final String msg = failLoadMsgHead + className + " from classloader " + classLoader + ", cause: " + e.toString();
                logger.warn(msg, e);
            } catch (IllegalAccessException | InstantiationException | NoSuchMethodException |
                     InvocationTargetException e) {
                final String msg = failLoadMsgHead + className + " from classloader " + classLoader + ", cause: " + e.toString();
                logger.error(msg, e);
            }
        }

        return ret;
    }
@author Jerry Lee (oldratlee at gmail dot com)
ttl-agent/src/main/java/com/alibaba/ttl3/agent/TtlExtensionTransformletManager.java