common_helper/src/main/java/com/xiongyingqi/util/ClassLookupHelper.java
public static Collection<Class<?>> getClasses(ClassFileFilter filter) {
        Set<URLClassLoader> loaders = new LinkedHashSet<URLClassLoader>(8);
        loaders.addAll(getClassLoaders(Thread.currentThread().getContextClassLoader()));
        loaders.addAll(getClassLoaders(ClassLookupHelper.class.getClassLoader()));

        Set<Class<?>> klasses = new LinkedHashSet<Class<?>>();
        for (URLClassLoader cl : loaders) {
            for (URL url : cl.getURLs()) {
                String file = url.getFile();
                if (file.endsWith(".jar") || file.endsWith(".zip")) {
                    lookupClassesInJar(null, url, true, cl, filter, klasses);
                } else {
                    lookupClassesInFileSystem(null, new File(file), true, cl, filter, klasses);
                }
            }
        }
        return klasses;
    }
public static Collection<Class<?>> getClasses(ClassFileFilter filter) {
        Set<URLClassLoader> loaders = new LinkedHashSet<URLClassLoader>(8);
        loaders.addAll(getClassLoaders(Thread.currentThread().getContextClassLoader()));
        loaders.addAll(getClassLoaders(ClassLookupHelper.class.getClassLoader()));

        Set<Class<?>> klasses = new LinkedHashSet<Class<?>>();
        for (URLClassLoader cl : loaders) {
            for (URL url : cl.getURLs()) {
                String file = url.getFile();
                if (file.endsWith(".jar") || file.endsWith(".zip")) {
                    lookupClassesInJar(null, url, true, cl, filter, klasses);
                } else {
                    lookupClassesInFileSystem(null, new File(file), true, cl, filter, klasses);
                }
            }
        }
        return klasses;
    }
public static Collection < Class < ? > > getClasses ( ClassFileFilter filter ) { Set < URLClassLoader > loaders = new LinkedHashSet < URLClassLoader > ( 8 ) ; loaders . addAll ( getClassLoaders ( Thread . currentThread ( ) . getContextClassLoader ( ) ) ) ; loaders . addAll ( getClassLoaders ( ClassLookupHelper . class . getClassLoader ( ) ) ) ; Set < Class < ? > > klasses = new LinkedHashSet < Class < ? > > ( ) ; for ( URLClassLoader cl : loaders ) { for ( URL url : cl . getURLs ( ) ) { String file = url . getFile ( ) ; if ( file . endsWith ( ".jar" ) || file . endsWith ( ".zip" ) ) { lookupClassesInJar ( null , url , true , cl , filter , klasses ) ; } else { lookupClassesInFileSystem ( null , new File ( file ) , true , cl , filter , klasses ) ; } } } return klasses ; }
从所有的 classpath 下面搜索指定的 Class
从所有的 classpath 下面搜索指定的 Class