Annotation Processing 101
summary
Explains how an annotation processor is written to generate a type-based Factory (rules: only classes, empty constructor, unique ID, must inherit the specified type), using JavaPoet to emit a create(id) method and writing processors via AbstractProcessor and the services file. Demonstrates compile-time benefits versus reflection: Logan Square cuts JSON parsing from ~60–70ms to 17ms, Dagger2 saves ~13% CPU, EventBus registrations rise to ~7,000/sec. Notes limitation: can only create new files and is no runtime reflection, so generated code is debuggable.
AI-written summary · about
chapters (8)
- 0:00Annotation processing intro
- 3:38Why it matters
- 9:21Limitations and debugging
- 17:01First annotation processor
- 21:20Handling errors and edge cases
- 29:13Code generation with JavaPoet
- 31:43Common pitfalls and fixes
- 35:18Performance trade-offs
related talks
30mYour own @Annotation processor
52mAnnotation Processing
01h 03mJava Annotation Processing
46mJava annotation processing magic for muggles
56mThe Wonders of Java Annotation Processing at Compile Time
45mExplaining annotation magic
50mRevealing the magic behind Java annotations
39mYour Program as a Transpiler
