JetBrains/intellij-community · error · CantRunException

IDEA cannot generate Javadoc as module-source-path cannot be

Error message

IDEA cannot generate Javadoc as module-source-path cannot be evaluated

What it means

With JDK 9+ and more than one module, the runner writes a --module-source-path argument computed by computeModuleSourcePath from the per-module source roots (e.g. 'mod1/*=dir1;mod2/*=dir2' patterns). If that computation returns null — roots cannot be mapped to the expected layout — CantRunException('module-source-path cannot be evaluated') aborts. This is an internal layout-analysis failure: typically a module's content roots do not fit the pattern the algorithm supports.

Source

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

            parameters.add("--source", String.valueOf(languageLevel.feature()));
            break;
          }
        }
      }

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

      Charset cs = CharsetToolkit.getPlatformCharset();
      try (PrintWriter writer = new PrintWriter(new OutputStreamWriter(new FileOutputStream(argsFile), cs))) {
        if (sourceRoots.size() + classRoots.size() > 0) {
          if (hasJavaModules && JavaSdkUtil.isJdkAtLeast(jdk, JavaSdkVersion.JDK_1_9)) {
            if (modules.size() > 1) {
              writer.println("--module-source-path");
              String moduleSourcePath = computeModuleSourcePath(moduleDescriptors);
              if (moduleSourcePath == null) {
                throw new CantRunException(JavaBundle.message("javadoc.gen.error.module.source.path.is.not.evaluated"));
              }
              writer.println(StringUtil.wrapWithDoubleQuote(moduleSourcePath));
            }
            else if (!sourceRoots.isEmpty()) {
              String path = sourceRoots.stream().map(MyJavaCommandLineState::localPath).collect(Collectors.joining(File.pathSeparator));
              writer.println("--source-path");
              writer.println(StringUtil.wrapWithDoubleQuote(path));
            }

            if (!classRoots.isEmpty()) {
              String path = classRoots.stream().map(MyJavaCommandLineState::localPath).collect(Collectors.joining(File.pathSeparator));
              writer.println("--module-path");
              writer.println(StringUtil.wrapWithDoubleQuote(path));
            }
          }
          else {
            // placing source roots on a classpath is perfectly legal and allows generating correct Javadoc
            // when a module without a module-info.java file depends on another module that has one

View on GitHub (pinned to be881553f2)

Solutions

  1. Check that every module in the scope has exactly one properly marked production Sources Root containing its module-info.java.
  2. Re-import the project (Gradle/Maven refresh) to regenerate a canonical content-root layout.
  3. If one module has an exotic layout, generate javadoc module-by-module with single-module scopes to isolate the offender.
Defensive patterns

Strategy: validation

Validate before calling

// Each module must have exactly one marked production source root containing module-info.java
for (Module m : modules) {
  List<VirtualFile> roots = OrderEnumerator.orderEntries(m).getSourcePathsList... // or ModuleRootManager.getSourceRoots()
  if (roots.stream().noneMatch(r -> r.findChild(PsiJavaModule.MODULE_INFO_FILE) != null)) { notify("Module " + m.getName() + " layout prevents module-source-path"); return; }
}

Prevention

When it happens

Trigger: Multi-module JPMS javadoc generation where a module's source roots are missing, duplicated in an ambiguous way, or arranged (e.g. several production roots per module) such that computeModuleSourcePath cannot construct the module-source-path string.

Common situations: Modules whose source root was deleted or is invalid; Gradle/Maven imports producing unusual content-root layouts; modules included via the javadoc scope without any marked source root.

Related errors


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