Esta página se muestra en inglés. Una traducción al español está en curso.
ScriptsMay 29, 2026·3 min de lectura

Error Prone — Catch Common Java Mistakes at Compile Time

A Java compiler plugin by Google that catches common programming mistakes as compile-time errors, integrated directly into the javac compilation process.

Listo para agents

Instalación lista para agent

Este activo puede instalarse después de elegir el runtime, revisar el plan y ejecutar el comando correspondiente.

Native · 98/100Política: permitir
Superficie agent
Cualquier agent MCP/CLI
Tipo
Skill
Instalación
Single
Confianza
Confianza: Established
Entrada
Error Prone Overview
Comando de instalación directa
npx -y tokrepo@latest install 4cd58a7f-5b15-11f1-9bc6-00163e2b0d79 --target codex

Ejecutar después de confirmar el plan con dry-run.

Introduction

Error Prone is a Java compiler plugin developed by Google that augments the standard javac compiler with additional checks. It catches bugs like null dereferences, incorrect equals implementations, and resource leaks at compile time rather than at runtime.

What Error Prone Does

  • Hooks into the javac compiler as a plugin to analyze code during compilation
  • Detects over 500 bug patterns including null safety, concurrency, and API misuse
  • Provides suggested fixes that can be applied automatically via patching
  • Supports custom check authoring using the Error Prone API
  • Integrates with Bazel, Maven, and Gradle build systems

Architecture Overview

Error Prone runs as a javac annotation processor plugin. It receives the full compiler AST after type resolution, giving each check access to resolved types, symbols, and control flow information. Checks are implemented as BugChecker classes that match specific AST patterns using a visitor API. Suggested fixes are expressed as source-level patches.

Self-Hosting & Configuration

  • Add Error Prone as an annotation processor path in Maven or Gradle compiler configuration
  • For Bazel projects, Error Prone is enabled by default in the Java rules
  • Disable specific checks with -Xep:CheckName:OFF compiler flags
  • Promote warnings to errors with -Xep:CheckName:ERROR for stricter enforcement
  • Use @SuppressWarnings("ErrorProneCheckName") for inline suppression

Key Features

  • Over 500 built-in bug checks developed from Google's internal codebase experience
  • Runs at compile time with no separate analysis step required
  • Suggested fixes that can be applied as automated refactoring patches
  • Severity levels (ERROR, WARNING, SUGGESTION) for each check
  • Support for writing custom checks using the Error Prone Check API

Comparison with Similar Tools

  • SpotBugs — analyzes compiled bytecode for bugs; Error Prone works at the source level during compilation
  • Checkstyle — enforces code style conventions; Error Prone focuses on semantic correctness bugs
  • PMD — finds code smells and unused code via static analysis; Error Prone catches deeper type-level bugs
  • NullAway — an Error Prone plugin that adds comprehensive null safety checking on top of the base checks

FAQ

Q: Does Error Prone slow down compilation? A: The overhead is typically 10-20% on compilation time, which is offset by catching bugs before tests run.

Q: Can I use Error Prone with Kotlin or other JVM languages? A: Error Prone works only with javac and Java source files. It does not analyze Kotlin or Scala code.

Q: How do I apply suggested fixes automatically? A: Use the -XepPatchChecks and -XepPatchLocation flags to generate patch files, then apply them with the Error Prone patching tool.

Q: Is Error Prone used at Google? A: Yes. Error Prone is used across Google's Java codebase and many of its checks originate from bugs found in production.

Sources

Discusión

Inicia sesión para unirte a la discusión.
Aún no hay comentarios. Sé el primero en compartir tus ideas.

Activos relacionados