10 Tips to Make Libraries Kotlin-Friendly
summary
Ten concrete Java-to-Kotlin interoperability rules: use nullability annotations but treat them as compile-time contracts (loosening inputs and tightening outputs affects backward compatibility); avoid Java identifiers that are Kotlin keywords; beware extension-method and infix/operator shadowing; prefer JavaBean-style getters for Kotlin property access; add componentN methods to enable Kotlin destructuring; avoid overloads that confuse SAM lambdas or varargs; order function parameters so lambda is last. Also a Checkstyle-based linter exists on GitHub and is published to Maven to catch several of these issues.
AI-written summary · about
chapters (13)
- 0:00Introduction and context
- 1:24Designing for compatibility
- 6:15Nullability annotations
- 12:46Avoiding Kotlin keywords
- 14:26Extension method conflicts
- 18:21Property inference
- 20:03Operator overloading
- 22:42Infix function shadowing
- 26:34Varargs ambiguity
- 28:45Implementing destructuring
- 31:37Functional interface issues
- 33:40Parameter ordering
- 36:50Tools and summary
related talks
50mWriting Java-friendly Kotlin Code
39mTeach Kotlin to play well with Java - Optimization tips for Interoperability
36mBest practices for evolving Kotlin libraries
43mIdiomatic Interop
42mIdiomatic Interop with Kotlin
38mKids, Play Nice! - Writing With Kotlin-Java Interop
17mKotlin Library API Design and Compatibility Challenges
42mKotlin Not-to-Do List - What we should avoid doing in Kotlin
