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

Error Prone — Catch Common Java Mistakes at Compile Time

Error Prone is a static analysis tool by Google that plugs into the Java compiler to catch common programming mistakes as compile-time errors rather than runtime bugs.

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 b4e7cfb7-802a-11f1-9bc6-00163e2b0d79 --target codex

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

Introduction

Error Prone is a compile-time static analysis tool by Google that hooks into javac to detect common Java programming errors. Unlike standalone linters, it runs during compilation and surfaces issues as compiler errors or warnings, catching bugs before code ever runs.

What Error Prone Does

  • Detects hundreds of common Java bug patterns during compilation
  • Produces compiler errors or warnings with clear fix suggestions
  • Integrates with Maven, Gradle, and Bazel build systems
  • Allows teams to write custom bug pattern checkers
  • Provides automatic refactoring patches for many detected issues

Architecture Overview

Error Prone operates as a javac plugin that analyzes the abstract syntax tree (AST) during compilation. Each bug pattern is implemented as a BugChecker class that inspects specific AST nodes. When a pattern matches, Error Prone emits a diagnostic with a human-readable description and often a suggested fix that can be applied automatically.

Self-Hosting & Configuration

  • Add as a dependency to Maven, Gradle, or Bazel build configuration
  • Requires JDK 11 or later
  • Enable or disable specific checks via compiler flags
  • Promote warnings to errors or demote errors to warnings per check
  • Write custom BugChecker classes for project-specific patterns

Key Features

  • 500+ built-in bug pattern detectors covering null safety, concurrency, and API misuse
  • Automatic fix suggestions that can be applied with a single command
  • Runs at compile time with minimal build overhead
  • Extensible: teams can write and distribute custom checkers
  • Battle-tested across Google internal codebase at massive scale

Comparison with Similar Tools

  • SpotBugs — Analyzes bytecode post-compilation; Error Prone works at the source level during compilation
  • PMD — Rule-based standalone linter; Error Prone integrates directly into javac
  • SonarQube — Server-based analysis platform; Error Prone is a lightweight compiler plugin
  • Checkstyle — Focuses on style and formatting; Error Prone focuses on correctness bugs

FAQ

Q: Does Error Prone slow down compilation? A: Overhead is typically under 10%, as it piggybacks on the existing compilation pass.

Q: Can I use it with Kotlin? A: No. Error Prone analyzes Java source code via javac. For Kotlin, consider detekt.

Q: How do I suppress a false positive? A: Use the @SuppressWarnings annotation with the check name.

Q: Is it used in production at Google? A: Yes. Error Prone is used across the entire Google Java codebase.

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