kotlin-java-library
Installation
SKILL.md
Kotlin Java Library Design
Quick start
- Read
references/kotlin-java-library.mdbefore changing public Kotlin APIs for Java consumers. - Design Kotlin APIs as if the primary caller is Java: explicit overloads, stable names, and predictable nullability.
- Use JVM interop annotations (
@JvmOverloads,@JvmStatic,@JvmField,@JvmName) to shape the Java surface. - Prefer Java-friendly top-level functions with
@file:JvmName, and use@file:JvmMultifileClasswhen splitting across files. - Use
fun interfacefor Java callbacks; avoid function types that returnUnit. - Document checked exceptions with
@Throwsand return defensive copies for read-only collections. - Follow binary compatibility rules: add overloads or new members instead of changing published signatures.
- Validate examples with
scripts/verify-examples.javawhen changing the reference or public API patterns.
Workflow
- Identify which public APIs must be Java-friendly (constructors, factories, utilities, callbacks, records).
- Shape the Java surface with JVM annotations and explicit overloads.
- Audit public signatures for Java stability (names, nullability, overload sets, and collection exposure).
- Apply backward-compatibility rules before publishing; treat
@PublishedApimembers as public. - Validate with Java call-site examples.
- Run
jbang skills/kotlin-java-library/scripts/verify-examples.java; if it fails, fix the sample or document why it cannot be tested.