Annotation Preprocessing in Android
summary
Annotation processing is presented as a way to generate classes at compile time to avoid reflection and runtime bytecode gen that slow Android startup (examples cite a ~700 ms delay). Concrete tools and libs: Dagger 2, Retrofit, MapStruct, Lombok use APT; JavaPoet builds source, Google AutoService registers processors, and compile-testing verifies output. Example: a factory annotation auto-generates an if‑chain factory class; caveats include multi‑round processing and brittle build-system integration, but generated code runs with native performance.
AI-written summary · about
chapters (15)
- 0:00Introduction and speaker background
- 1:08What is annotation processing
- 3:16Boilerplate code in development
- 5:31Reflection and code generation issues
- 7:46Why annotation processing for Android
- 9:37Annotation processor basics
- 13:38Creating a simple annotation processor
- 19:27Processing annotated elements
- 23:04Generating source files with JavaPoet
- 26:19Processing rounds and testing
- 27:47Frameworks using annotation processing
- 31:23Project Lombok deep dive
- 33:54Lombok features and benefits
- 34:39Custom frameworks with annotation processing
- 35:00Conclusion and Q&A
