Java
Language guide. No Spring / Jakarta religion. No scripts/.
Process skills that may load with this one: load-with list.
Iron law
Nulls are explicit. Resources close themselves. Dependencies point inward.
Tooling / verify
# one of these, as the repo does
mvn -q test
gradle test
Do not add a second build tool. Read the surefire/gradle test output.
Idioms a linter misses
- Records / sealed types when the language level allows and the type is data.
- Try-with-resources for every
AutoCloseable. - Constructor injection. Do not
newa service inside another service if the module already injects. - Never return
nullfor a collection; return empty. equalsandhashCodetogether. Prefer records.- Prefer
finallocals when the file already does. No clever var shadowing. java.timeoverDate/Calendarfor new code.
Errors
- Specific exceptions. Wrap with cause. Do not catch
Exceptionto return null. - Checked exceptions: do not punch them through a listener that cannot declare them — map at the boundary.
Concurrency
- Prefer
java.util.concurrentover home-rolled wait/notify. - Virtual threads: only if the project already uses them or the language level is there and you Ask first before flipping a thread model.
- No unsynchronized shared mutable state.
synchronizedonthisis usually the wrong lock object for public types.
Testing
- JUnit as the repo uses it. Assert on behavior, not log strings.
- Test doubles at I/O boundaries. Do not mock the type under test.
PR review
- New public API: null contract documented or non-null by type
(
Optionalonly when absence is the point). - No leaked persistence entities across a module boundary.
- Module / package cycles.
Security
- No string-built SQL or process commands.
Runtime.exec/ProcessBuilder: argument list, not a shell string.- No
ObjectInputStream/ Java serialization of untrusted bytes. - Paths stay inside an allowlisted root.
Always
- Try-with-resources.
- Empty collections, not null lists.
- Tests for the new branch.
Ask first
- Bumping the language level.
- Adding Spring / Jakarta annotations in a non-Spring module.
- Switching thread model to virtual threads.
Never
- Empty
catch (Exception e) {}. - Public mutable static state.
- Raw types.
Runtime.execwith concatenated input.
Red flags
- "I'll null-check it at every call"
- "Spring will wire it" on a type that is not a bean
- "it's just a static Map"