Java Standard

Java Standard

Non-Negotiables

  1. Google Java Style is the default. No local “taste”.
  2. Fail-fast over silent failure. Every exception must be either handled, wrapped, or rethrown with context.
  3. Public APIs are contracts. Changes must be backwards compatible or versioned.
  4. Security is part of correctness. Unsafe code is broken code.

Minimum Requirements (Industry Standard Baseline)

Formatting & Style

  • Follow Google Java Style (imports, braces, naming, whitespace).
  • One formatter only (no editor wars): google-java-format.
  • No unchecked warnings ignored without justification (@SuppressWarnings must be narrow and documented).

Language & API Usage

  • Prefer immutability: final by default for variables and fields.
  • Avoid Optional as a field/parameter type; use it primarily for return values.
  • Never use == for string equality.
  • No reflection for business logic unless there is a documented framework reason.

Error Handling

  • Do not swallow exceptions.
  • Wrap lower-level exceptions at boundaries with:
    • stable error code (or exception type)
    • contextual message
    • original cause attached
  • Do not leak internal exception messages to external clients.

Concurrency

  • No shared mutable state without explicit synchronization.
  • Use java.util.concurrent primitives; avoid ad-hoc locks.
  • Timeouts are mandatory for IO and remote calls.

Testing

  • New logic must be covered by unit tests.
  • Integration tests are required for DB/network boundaries.
  • Flaky tests are production incidents in disguise—fix or quarantine immediately.

Static Analysis (Must Be Green)

  • Lint rules are a merge gate (Checkstyle/SpotBugs/ErrorProne where applicable).
  • 0 blocker/critical issues in quality gate tooling.

References (Read the Standard, Don’t Re-interpret It)