Idiomatic Interop
summary
Explains concrete interop fixes: use @JvmOverloads instead of piling telescoping constructors, add @JvmStatic or use file-level @file:JvmName to expose clean Java APIs, and annotate Kotlin interfaces with @Throws so Java can implement methods that throw checked exceptions. Notes nullability pain: hundreds of Java annotations in one codebase, about 475 annotated so far, and recommends JSR‑305-style defaults via package-info.java to eliminate platform types. Gives workarounds for inline reified generics (add a Class<T> overload) and suggests builders for data classes to make Java callers sane.
AI-written summary · about
chapters (29)
- 0:00Intro
- 0:43Doesnt Kotlin already have 100% interop?
- 1:15Who should be thinking about this?
- 2:16Your interop story should be
- 3:16@Jvm Annotations
- 4:32Don't get too carried away
- 6:29A less nested way?
- 8:35@Throws
- 11:46Extension functions
- 13:37Inline functions
- 14:46Reified generics workaround
- 15:41Visibility
- 16:04internal
- 17:26Package-local
- 18:04private
- 19:11Nullability Annotations!
- 24:46Annotating a package
- 25:27DIY Default Nullability Annotations
- 27:39Living the dream
- 27:56Nulls in libraries
- 29:30Lambdas and SAMS
- 32:08Lambda signatures
- 33:12Unit
- 34:18Nothing
- 36:12Wildcards
- 39:34Data classes
- 41:40Overall Interop Thoughts
- 42:12Quick Tip
- 42:55Resources
related talks
42mIdiomatic Interop with Kotlin
39mTeach Kotlin to play well with Java - Optimization tips for Interoperability
38mKids, Play Nice! - Writing With Kotlin-Java Interop
50mWriting Java-friendly Kotlin Code
36mKotlin, Beyond the Basics
41m10 Tips to Make Libraries Kotlin-Friendly
47mKotlin’s Mind Blowers²
46mThe Road to Kotlintown
