Java: Reflection is dead, long live annotation processing!
summary
Claim: replace runtime reflection with compile‑time annotation processing to avoid runtime overhead and make generated code debuggable. Evidence: a microbenchmark shows reflective instantiation is 6–10× slower than direct construction. Tools used: JSR-269 annotation processors invoked by javac, the Processing/Filer/TypeElement APIs, optional JavaPoet, plus a homemade bytecode name-changer and compiler plugins for tasks not possible in processors. Built: a factory generator that writes source switch cases, then renames generated class files to original names — brittle but effective.
AI-written summary · about
chapters (10)
- 0:00Introduction and speaker background
- 2:16Reflection controversy and talk agenda
- 4:41Replacing conditionals with polymorphism
- 8:57Reflection performance costs
- 15:07Annotation processing fundamentals
- 23:45Factory pattern with annotation processing
- 31:02Handling generated class visibility
- 33:53Bytecode manipulation challenges
- 40:43Compiler plugins alternative
- 42:51Q&A session
