class LocalEnvironment implements Environment {

    @Override
    public ClassLoader getClassLoader( Object caller,
                                       String... classpathEntries ) {
        caller = Objects.requireNonNull(caller);

        Set<ClassLoader> delegates = new LinkedHashSet<>();

        List<String> urls = Arrays.stream(classpathEntries).filter(StringUtil::notBlank).collect(Collectors.toList());
        if (urls.isEmpty()) {
            StringURLClassLoader urlClassLoader = new StringURLClassLoader(urls);
            // only if any custom urls were parsed add this loader
            if (urlClassLoader.getURLs().length > 0) {
                delegates.add(urlClassLoader);
            }
        }

        ClassLoader currentLoader = getClass().getClassLoader();
        ClassLoader callerLoader = caller.getClass().getClassLoader();
        ClassLoader tccl = Thread.currentThread().getContextClassLoader();
        
        //add the TCCL to the list if it's not the same as the current loader or the fallback loader
        if (!callerLoader.equals(tccl) && !currentLoader.equals(tccl)) {
            delegates.add(tccl);
        }

        if (!callerLoader.equals(currentLoader)) {
            // if the parent of fallback is the same as the current loader, just use that
            if (currentLoader.equals(callerLoader.getParent())) {
                currentLoader = callerLoader;
            } else {
                delegates.add(callerLoader);
            }
        }

        return delegates.isEmpty() ? currentLoader : new DelegatingClassLoader(currentLoader, delegates);
    }

    public  LocalEnvironment();

}