public Set<Class<?>> findClasses(String packageName, boolean proceedOnExceptions)
    throws ClassNotFoundException, IOException, LinkageError {
    final String path = packageName.replace('.', '/');
    final Pattern jarResourceRe = Pattern.compile("^file:(.+\\.jar)!/" + path + "$");

    Enumeration<URL> resources = this.classLoader.getResources(path);
    List<File> dirs = new ArrayList<>();
    List<String> jars = new ArrayList<>();

    while (resources.hasMoreElements()) {
      URL resource = resources.nextElement();
      String resourcePath = resource.getFile();
      Matcher matcher = jarResourceRe.matcher(resourcePath);
      boolean isJar = matcher.find();
      resourcePath = isJar ? matcher.group(1) : resourcePath;
      if (
        null == this.resourcePathFilter
          || this.resourcePathFilter.isCandidatePath(resourcePath, isJar)
      ) {
        LOG.debug("Looking in " + resourcePath + "; isJar=" + isJar);
        if (isJar) {
          jars.add(resourcePath);
        } else {
          dirs.add(new File(resourcePath));
        }
      }
    }

    Set<Class<?>> classes = new HashSet<>();
    for (File directory : dirs) {
      classes.addAll(findClassesFromFiles(directory, packageName, proceedOnExceptions));
    }
    for (String jarFileName : jars) {
      classes.addAll(findClassesFromJar(jarFileName, packageName, proceedOnExceptions));
    }
    return classes;
  }
Finds the classes in a package and nested packages.
@param packageName         package names
@param proceedOnExceptions whether to ignore exceptions encountered for individual
                           jars/files/classes, and proceed looking for others.
hbase-common/src/test/java/org/apache/hadoop/hbase/ClassFinder.java