common_helper/src/main/java/com/xiongyingqi/util/ClassLookupHelper.java
public static Set<Class<?>> getClasses(String packageName, boolean recursive, ClassFileFilter filter) {
        if (packageName == null || packageName.length() == 0) {
            throw new IllegalArgumentException("packageName is empty.");
        }

        ClassLoader loader = Thread.currentThread().getContextClassLoader();
        String packageDirName = packageName.replace('.', '/');
        Collection<URL> urls;
        try {
            Enumeration<URL> dirs = loader.getResources(packageDirName);
            urls = Collections.list(dirs);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }

        Set<Class<?>> klasses = new LinkedHashSet<Class<?>>();
        for (URL url : urls) {
            String protocol = url.getProtocol();
            if ("file".equals(protocol)) {
                lookupClassesInFileSystem(packageName, new File(url.getFile()), recursive, loader, filter, klasses);
            } else if ("jar".equals(protocol)) {
                lookupClassesInJar(packageName, url, recursive, loader, filter, klasses);
            }
        }
        return klasses;
    }
public static Set<Class<?>> getClasses(String packageName, boolean recursive, ClassFileFilter filter) {
        if (packageName == null || packageName.length() == 0) {
            throw new IllegalArgumentException("packageName is empty.");
        }

        ClassLoader loader = Thread.currentThread().getContextClassLoader();
        String packageDirName = packageName.replace('.', '/');
        Collection<URL> urls;
        try {
            Enumeration<URL> dirs = loader.getResources(packageDirName);
            urls = Collections.list(dirs);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }

        Set<Class<?>> klasses = new LinkedHashSet<Class<?>>();
        for (URL url : urls) {
            String protocol = url.getProtocol();
            if ("file".equals(protocol)) {
                lookupClassesInFileSystem(packageName, new File(url.getFile()), recursive, loader, filter, klasses);
            } else if ("jar".equals(protocol)) {
                lookupClassesInJar(packageName, url, recursive, loader, filter, klasses);
            }
        }
        return klasses;
    }
从指定 package 中获取所有的 Class

@param packageName 包名
@param recursive   是否递归查找
@param filter      class 过滤器
@return 所有找到的 Class