skip to content

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 pageshow

explore

questions

page 2 of 2

You 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 s

Add @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.

open as a page

showing 31–31 of 31