JetBrains/intellij-community · error · CompilationException

Compilation failed

Error message

Compilation failed

What it means

Error "Compilation failed" thrown in JetBrains/intellij-community.

Source

Thrown at java/compiler/impl/src/com/intellij/compiler/CompilerManagerImpl.java:513

    final ExternalJavacManager javacManager = getJavacManager();
    final CompilationPaths paths = CompilationPaths.create(platformCp, classpath, upgradeModulePath, ModulePath.create(modulePath), sourcePath);
    // do not keep process alive in tests since every test expects all spawned processes to terminate in teardown
    boolean compiledOk = javacManager != null && javacManager.forkJavac(
      javaHome, -1, Collections.emptyList(), options, paths, files, outs, diagnostic, outputCollector,
      new JavacCompilerTool(), CanceledStatus.NULL, !ApplicationManager.getApplication().isUnitTestMode()
    ).get();

    if (!compiledOk) {
      final List<CompilationException.Message> messages = new SmartList<>();
      for (Diagnostic<? extends JavaFileObject> d : diagnostic.getDiagnostics()) {
        final JavaFileObject source = d.getSource();
        final URI uri = source != null ? source.toUri() : null;
        messages.add(new CompilationException.Message(
          kindToCategory(d.getKind()), d.getMessage(Locale.US), uri != null? uri.toURL().toString() : null, (int)d.getLineNumber(), (int)d.getColumnNumber()
        ));
      }
      throw new CompilationException("Compilation failed", messages);
    }

    final List<ClassObject> result = new ArrayList<>();
    for (OutputFileObject fileObject : outputCollector.getCompiledClasses()) {
      final BinaryContent content = fileObject.getContent();
      result.add(new CompiledClass(fileObject.getName(), fileObject.getClassName(), content != null ? content.toByteArray() : null));
    }
    return result;
  }

  private static boolean isJdkOrJre(@Nullable String path) {
    return path != null && (JdkUtil.checkForJre(path) || JdkUtil.checkForJdk(path));
  }

  private static CompilerMessageCategory kindToCategory(Diagnostic.Kind kind) {
    return switch (kind) {
      case ERROR -> CompilerMessageCategory.ERROR;
      case MANDATORY_WARNING, WARNING -> CompilerMessageCategory.WARNING;

View on GitHub (pinned to be881553f2)

Solutions

  1. Open the Build tool window or Messages view and fix the reported compile errors.
  2. Rebuild the project (Build | Rebuild Project) after fixing the errors.

Example fix

Fix the error listed in Messages Build, e.g. add the missing import or dependency, then Build | Build Project.

When it happens

Trigger: javac or another compiler task reports errors during a project build.

Common situations: Source errors such as missing symbols, wrong types, missing dependencies, or an invalid annotation processor on the module path.


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