JetBrains/intellij-community · error · CantRunException

IDEA cannot generate Javadoc as modules {0} do not contain m

Error message

IDEA cannot generate Javadoc as modules {0} do not contain module-info.java file

What it means

When at least one collected source is module-info.java (hasJavaModules) but some modules that were scanned lack one, generation aborts: merging javadoc for JPMS and non-JPMS modules into shared output (index.html, index-all.html) is not supported, so IDEA refuses instead of producing broken output. The message lists exactly which module names are missing module-info.java.

Source

Thrown at java/java-impl/src/com/intellij/javadoc/JavadocGeneratorRunProfile.java:271

      Set<Module> modulesWithoutDescriptor = new HashSet<>(modules);
      Map<Module, VirtualFile> moduleDescriptors = new HashMap<>();
      boolean hasJavaModules = false;
      for (VirtualFile source : sources) {
        if (!PsiJavaModule.MODULE_INFO_FILE.equals(source.getName())) {
          continue;
        }
        hasJavaModules = true;
        Module module = ModuleUtilCore.findModuleForFile(source, myProject);
        if (module != null) {
          moduleDescriptors.put(module, source);
          modulesWithoutDescriptor.remove(module);
        }
      }
      if (hasJavaModules && !modulesWithoutDescriptor.isEmpty()) {
        // So far we can't generate javadoc for each module independently as we have to merge the results into common files,
        // e.g index.html, index-all.html and so on. Moreover, the final javadoc seems obscured in the case when one module contains
        // module-info file but another one is not.
        throw new CantRunException(JavaBundle.message("javadoc.gen.error.modules.without.module.info", modulesWithoutDescriptor.stream()
          .map(m -> "'" + m.getName() + "'").collect(Collectors.joining(","))));
      }

      if (JavaSdkVersionUtil.isAtLeast(jdk, JavaSdkVersion.JDK_11)) {
        for (Module module : modules) {
          LanguageLevel languageLevel = LanguageLevelUtil.getEffectiveLanguageLevel(module);
          if (languageLevel.isPreview()) {
            parameters.add(JavaParameters.JAVA_ENABLE_PREVIEW_PROPERTY);
            parameters.add("--source", String.valueOf(languageLevel.feature()));
            break;
          }
        }
      }

      File argsFile = createTempArgsFile();
      List<VirtualFile> sourceRoots = findSourceRoots(modules);
      List<VirtualFile> classRoots = findClassRoots(modules, jdk);

View on GitHub (pinned to be881553f2)

Solutions

  1. Narrow the javadoc scope to only the modules that have module-info.java, generating per-module sets.
  2. Or add a module-info.java to every module named in the error message so the selection becomes uniform.
  3. Or temporarily deselect the non-modular modules from the scope/package list in the Generate JavaDoc dialog.
Defensive patterns

Strategy: validation

Validate before calling

// Ensure scope is uniform: all selected modules have module-info.java, or none do
boolean any = modulesInScope.stream().anyMatch(m -> hasModuleInfo(m));
boolean all = modulesInScope.stream().allMatch(m -> hasModuleInfo(m));
if (any && !all) { notify("Scope mixes JPMS and non-JPMS modules — narrow it or add module-info.java"); return; }

Prevention

When it happens

Trigger: Selecting a scope spanning multiple modules where some are JPMS modules (with module-info.java) and others are classic classpath modules, then running Tools | Generate JavaDoc.

Common situations: Mixed projects mid-migration to JPMS; utility/legacy modules intentionally left without module descriptors; scopes that accidentally include test or generated modules without module-info.

Related errors


AI-assisted analysis of JetBrains/intellij-community@be881553f2 (2026-08-14). Data as JSON: /api/errors/22a4572b57babfd2. Report an issue: GitHub.