Java Standard
Java Standard
Non-Negotiables
- Google Java Style is the default. No local “taste”.
- Fail-fast over silent failure. Every exception must be either handled, wrapped, or rethrown with context.
- Public APIs are contracts. Changes must be backwards compatible or versioned.
- 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 (
@SuppressWarningsmust be narrow and documented).
Language & API Usage
- Prefer immutability:
finalby default for variables and fields. - Avoid
Optionalas 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.concurrentprimitives; 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)
- Google Java Style Guide: https://google.github.io/styleguide/javaguide.html
- google-java-format: https://github.com/google/google-java-format
- Effective Java (3rd Edition): https://www.oreilly.com/library/view/effective-java-3rd/9780134686097/
- OWASP ASVS (security requirements): https://owasp.org/www-project-application-security-verification-standard/