Skip to content

Adopt ErrorProne (or equivalent) to catch unused private fields and similar javac blind spots #554

@khatchad

Description

@khatchad

Motivation

ponder-lab/ML#337 removes TENSOR_ITERABLE_SYNTHETIC_FUNCTION_NAME — an unused private static final field in PythonTensorAnalysisEngine that had been orphaned. The constant slipped through despite the project's <compilerArgument>-Xlint</compilerArgument> + <failOnWarning>true</failOnWarning> config.

Spike verified the root cause: javac doesn't detect unused private fields at all, not even under -Xlint:all. Repo-wide compile under -Xlint:all,-options with failOnWarning=false emits 0 warnings. The "unused private field" detection is outside javac's native lint surface — it requires a separate static-analysis tool.

This is a systemic blind spot. The single orphan caught here was visible only because it surfaced during a CLAUDE.md rewrite that referenced it; other unused-private fields could be lurking unflagged.

Proposed Direction

Adopt one of:

  1. ErrorProne (https://errorprone.info) — javac plugin, integrates as a maven-compiler-plugin annotation processor. The UnusedVariable check covers unused fields/locals/parameters. Many other checks come along (EqualsHashCode, MissingOverride, etc.). The standard choice for Google-style javac integration.
  2. SpotBugs — separate maven plugin, bytecode-level. UUF_UNUSED_FIELD covers this case. Different category of tool; runs after compile rather than during.
  3. PMD — source-level, narrower coverage; less commonly used.

Recommendation: ErrorProne, since it's the closest match to "javac warnings the project already runs" — same compile-time triggering, just more aggressive checks.

One-Time Cleanup Cost

Adopting any of these will surface existing warnings that need fixing in one pass before failOnWarning can be re-enabled. Pre-adoption spike (run the tool with warnings-only, no fail) gives a count.

Related

  • ponder-lab/ML#337 — the single-orphan removal that surfaced the gap.
  • The project's existing maven-compiler-plugin config at pom.xml:159-160.

Metadata

Metadata

Assignees

No one assigned

    Labels

    cleanuptestingRelated to test code or test input

    Type

    No fields configured for Task.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions