private Set<Class<?>> findClassesFromFiles(File baseDirectory, String packageName,
    boolean proceedOnExceptions) throws ClassNotFoundException, LinkageError {
    Set<Class<?>> classes = new HashSet<>();
    if (!baseDirectory.exists()) {
      LOG.warn(baseDirectory.getAbsolutePath() + " does not exist");
      return classes;
    }

    File[] files = baseDirectory.listFiles(this.fileFilter);
    if (files == null) {
      LOG.warn("Failed to get files from " + baseDirectory.getAbsolutePath());
      return classes;
    }

    for (File file : files) {
      final String fileName = file.getName();
      if (file.isDirectory()) {
        classes
          .addAll(findClassesFromFiles(file, packageName + "." + fileName, proceedOnExceptions));
      } else {
        String className =
          packageName + '.' + fileName.substring(0, fileName.length() - CLASS_EXT.length());
        Class<?> c = makeClass(className, proceedOnExceptions);
        if (c != null) {
          if (!classes.add(c)) {
            LOG.warn("Ignoring duplicate class " + className);
          }
        }
      }
    }
    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