private static void logDetectedClasses(boolean useAppCDS,
                                         File targetFile,
                                         Collection<Class<?>> allClasses) {
    final Path basePath;
    try {
      basePath = new File(".").getCanonicalFile().toPath();
    }
    catch (IOException e) {
      throw new RuntimeException("Failed to resolve current working directory path", e);
    }

    ClassesLogger logger = new ClassesLogger(basePath, useAppCDS);
    //first output classes without getProtectionDomain().getCodeSource().getLocation, aka likely JDK classes

    Set<Class<?>> withoutSource = new HashSet<>();
    Set<Class<?>> libSource = new HashSet<>();
    Set<Class<?>> pluginsSource = new HashSet<>();

    allClasses.stream().sorted(Comparator.comparing(clazz -> clazz.getName())).forEach(clazz -> {
      String source = getSourceForClassesList(basePath, clazz);
      if (source == null) {
        withoutSource.add(clazz);
      }
      else if (!source.contains("plugins/")) {
        libSource.add(clazz);
      }
      else {
        pluginsSource.add(clazz);
      }
    });

    logger.addComment("System CDS block " + withoutSource.size() + " classes");

    ///we will see that class too often in the list, let's make it have and ID=1
    logger.logClass(Object.class);

    logger.attachClasses(withoutSource);

    if (useAppCDS) {
      logger.addComment("\n\nApplication CDS block, " + (libSource.size() + pluginsSource.size()) + " classes");
      logger.attachClasses(libSource);
      logger.attachClasses(pluginsSource);
    }
    else {
      logger.addComment("\n\nApplication CDS is DISABLED, skipping " + libSource.size() + pluginsSource.size() + " classes ");
    }

    try {
      logger.writeClassesList(targetFile);
    }
    catch (Throwable e) {
      log("Failed to write report file to " + targetFile, e);
    }

    log("===================================================");
    log("Created classes list file to " + targetFile);
    log("System classes: " + withoutSource.size());
    log("Application classes: " + (libSource.size() + pluginsSource.size()));
    log("AppCDS is " + (useAppCDS ? "enabled" : "DISABLED"));
    log("===================================================");
  }
private static void logDetectedClasses(boolean useAppCDS,
                                         File targetFile,
                                         Collection<Class<?>> allClasses)