Kotlin Intrinsics on Android
Article Summary
Rahul Ravikumar reveals how Android's tooling has been quietly carrying the weight of Kotlin's type safety. Every null check, every parameter validation adds overhead that pure Kotlin apps don't actually need.
When Kotlin compiles to JVM bytecode, it sprinkles Intrinsics checks everywhere to provide helpful error messages for Java callers. But if your entire app is Kotlin, these checks are pure overhead, bloating your dex file with unnecessary strings and method calls.
Key Takeaways
- AGP 9.0 automatically replaces Intrinsics.checkNotNull() with efficient getClass() calls
- Compose PokedexScrollBenchmark shows measurable frame duration improvements after optimization
- ART has native intrinsic for getClass(), compiling to extremely efficient assembly
- Eliminates string constants from dex pool while preserving null safety semantics
Critical Insight
Android Gradle Plugin 9.0 eliminates Kotlin's null-safety overhead automatically, giving you type safety at compile time and better runtime performance without any developer intervention.