Calling Kotlin From Java
The other direction: how your Kotlin declarations appear to a Java caller, and the annotations you add so they appear sensibly. Library authors are expected to know this cold.
part ofKotlinoverview, primer and where to startread it →on this pageshowhide
explore
- @JvmStatic5 questions
- @JvmField5 questions
- @JvmOverloads5 questions
- @JvmName & @file:JvmName5 questions
- @Throws For Checked Exceptions5 questions
- Companion & Top-Level Access From Java6 questions
questions
page 2 of 2You own a Kotlin library consumed by both Kotlin and Java teams. Design a policy for using @Throws across the public API, addressing compatibility, documentation, and the trade-offs of exposing checked-exception contracts.
level: principalimportance: nice to knowfreq 14%
basics
~20 sAdd @Throws only on public methods Java teams call that genuinely throw a checked exception worth handling. Treat the throws clause as part of your binary contract: adding/removing it can break Java callers. Document it and keep it stable.
showing 31–31 of 31