Arun Sudharsan
08/02/2025, 7:04 PMkotlin.jvm.internal.Intrinsics
calls). These account for ~2% of our APK size.
• Solution: Added ProGuard -assumenosideeffects
rules to remove these internal assertion methods (checkNotNull
, checkParameterIsNotNull
, etc.).
• Effect: Functionality remains the same; only runtime safety checks are stripped out.
• Trade-offs (which we’re okay with):
◦ Crash stack traces may lose some detail
◦ Some Kotlin-generated safety information from Intrinsics.java
will be missing
Project context
• Codebase: ~97% Kotlin, ~3% Java (20+ files).
Concerns
• Kotlin → Kotlin calls: Should be safe since nullability contracts are enforced at compile time.
• Java → Kotlin calls: Potential risk, since a Kotlin method expecting non-null could be called with a nullable from Java.
Current approach
• We’re reviewing and testing all Java → Kotlin call sites.
• Running automation suite + manual QA for validation.
My questions
1. How safe is this approach in practice? Are there pitfalls we might be missing?
2. Is there a more automated / systematic way (beyond manual inspection + tests) to gain confidence that removing these null-safety checks won’t cause issues in production?
Would love to hear if anyone has tackled this before, or has suggestions for tooling / strategies to improve our conviction here. 🙏Pablichjenkov
08/02/2025, 7:29 PMephemient
08/02/2025, 11:35 PM// Java
foo(null)
// Kotlin
fun foo(input: String) {
println(input)
GlobalScope.launch {
theMissiles()
}
}
ephemient
08/02/2025, 11:36 PMephemient
08/02/2025, 11:40 PMfun <T> foo(input: T?): T = input as T
fun bar(input: String?): String = foo(input)
bar(null)
of course you wouldn't intentionally write that butephemient
08/02/2025, 11:42 PM