code: private static void getClassPackageNames(Class<?> clazz, Map<String, Class<?>> packageNames) {
      if (isPrivate(clazz)) {
        throw new IllegalArgumentException(PrettyPrinter.format(
            "Unable to inject an instance of %s because it is a private class.", clazz));
      } else if (!isPublic(clazz)) {
        packageNames.put(clazz.getPackage().getName(), clazz);
      }
  
      Class<?> enclosingClass = clazz.getEnclosingClass();
      if (enclosingClass != null) {
        getClassPackageNames(enclosingClass, packageNames);
      }
    }
docs: Visits classes to collect package names.
  
  @see {@link #getTypePackageNames}.