π¦ ClawHub
Java
by @ivangdavila
Write robust Java avoiding null traps, equality bugs, and concurrency pitfalls.
TERMINAL
clawhub install javaπ About This Skill
name: Java slug: java version: 1.0.1 description: Write robust Java avoiding null traps, equality bugs, and concurrency pitfalls. metadata: {"clawdbot":{"emoji":"β","requires":{"bins":["java","javac"]},"os":["linux","darwin","win32"]}}
Quick Reference
| Topic | File |
|-------|------|
| Nulls, Optional, autoboxing | nulls.md |
| Collections and iteration traps | collections.md |
| Generics and type erasure | generics.md |
| Concurrency and synchronization | concurrency.md |
| Classes, inheritance, memory | classes.md |
| Streams and CompletableFuture | streams.md |
| Testing (JUnit, Mockito) | testing.md |
| JVM, GC, modules | jvm.md |
Critical Rules
== compares references, not content β always use .equals() for stringsequals() must also override hashCode() β HashMap/HashSet break otherwiseOptional.get() throws if empty β use orElse(), orElseGet(), or ifPresent()ConcurrentModificationException β use Iterator.remove()new T() or instanceof Listvolatile ensures visibility, not atomicity β count++ still needs synchronizationInteger i = null; int x = i; crashesInteger == Integer uses reference for values outside -128 to 127 β use .equals()AutoCloseable, Java 7+thenApply vs thenCompose β compose for chaining CompletableFuturesserialVersionUID mismatch breaks deserialization β always declare explicitly