Generating Kotlin Code
summary
Generating Kotlin from schemas produces more concise, safer APIs (example: converting Square’s Wire protos to Kotlin constructors, immutable lists and data semantics) and requires explicit Java interop choices such as using @JvmField to preserve field access. KotlinPoet handles imports, nonlinear generation, code blocks and expression-body optimization; ASM plus Kotlin metadata proto lets bytecode be patched to add named/default parameters for Java libraries. Watch for reified methods becoming private, SAM/Unit lambda quirks, extension-function file-class naming hacks, and that KotlinPoet currently runs only on the JVM.
AI-written summary · about
chapters (12)
- 0:00Start
- 0:16Kotlin Cogeneration
- 0:46Kotlin as a Code Generator
- 2:49Why Would You Generate Kotlin Code as Opposed to Something like Java
- 6:55Builder Class
- 9:18Reified Types
- 11:39Extension Functions
- 17:54Convenience Functions
- 18:45String Format Syntax
- 27:53Jvm Bytecode
- 29:59Getter Method
- 33:55Multi-Platform Support
related talks
37mGenerating Kotlin Code
22mIntegrating Kotlin Code into the Gradle Build Process
44mExploiting Kotlin Metadata + Annotation Processing
34mKotlin: Uncovered
37mKotlin: Uncovered
15mKotlin for Test Automation
41mAnnotation Processing in a Kotlin World
33mMeta-programming with KSP and Kotlin compiler plugins
