Java Immutability

Immutable objects in modern Java: records in depth, defensive copies, immutable collection factories versus unmodifiable views, deep versus shallow immutability, final-field semantics and safe publication (JMM), and the withers pattern. Use when designing a value object, when a record has a List, Map or array component, when an accessor returns internal mutable state, when an "immutable" object is observed changing, or when deciding whether immutability is worth its allocation cost. Does not cover null validation in constructors (java-null-safety) or Optional usage (java-optional).

robsonkades a9ddf28 5 files · 24.1 KB Updated

File contents

robsonkades/agent-skills/tree/main/skills/java-immutability commit a9ddf2892d

Frequently asked questions

npx skillmds@latest add robsonkades/java-immutability