Cette page est affichée en anglais. Une traduction française est en cours.
ConfigsJul 15, 2026·2 min de lecture

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.

Prêt pour agents

Installation agent prête

Cet actif peut être installé après choix du runtime, vérification du plan et exécution de la commande adaptée.

Native · 98/100Policy : autoriser
Surface agent
Tout agent MCP/CLI
Type
Skill
Installation
Single
Confiance
Confiance : Established
Point d'entrée
Error Prone Overview
Commande d'installation directe
npx -y tokrepo@latest install b4e7cfb7-802a-11f1-9bc6-00163e2b0d79 --target codex

À exécuter après confirmation du plan en 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

Fil de discussion

Connectez-vous pour rejoindre la discussion.
Aucun commentaire pour l'instant. Soyez le premier à partager votre avis.

Actifs similaires