code: private void listDirectory(File directory,
                                 RelativeDirectory subdirectory,
                                 Set<JavaFileObject.Kind> fileKinds,
                                 boolean recurse,
                                 ListBuffer<JavaFileObject> resultList) {
          File d = subdirectory.getFile(directory);
          if (!caseMapCheck(d, subdirectory))
              return;
  
          File[] files = d.listFiles();
          if (files == null)
              return;
  
          if (sortFiles != null)
              Arrays.sort(files, sortFiles);
  
          for (File f: files) {
              String fname = f.getName();
              if (f.isDirectory()) {
                  if (recurse && SourceVersion.isIdentifier(fname)) {
                      listDirectory(directory,
                                    new RelativeDirectory(subdirectory, fname),
                                    fileKinds,
                                    recurse,
                                    resultList);
                  }
              } else {
                  if (isValidFile(fname, fileKinds)) {
                      JavaFileObject fe =
                          new RegularFileObject(this, fname, new File(d, fname));
                      resultList.append(fe);
                  }
              }
          }
      }
docs: Insert all files in subdirectory subdirectory of directory directory
  which match fileKinds into resultList