Skip to main content

Java interop checks

These six checks run only in JVM compilations. Use them for libraries that support Java callers.

The checks​

CheckReports
Companion function without JvmStaticCompanion functions without a static entry point.
Companion property without static accessCompanion accessors without static access.
Default parameters without JvmOverloadsDefault parameters that Java callers can't omit.
Kotlin-only API without JvmSyntheticKotlin-specific function shapes visible to Java.
Mangled JVM names in public APIValue-class signatures that Java sources can't call.
Top-level API without JvmNameFile facades whose names depend on source file names.

Kotlin-only audience​

For a library without Java callers, disable the group:

build.gradle.kts
apiWatchdog {
javaInterop {
enabled = false
}
}

enabled defaults to true. false overrides every per-check severity.

Per-declaration exceptions​

To exempt one declaration, use the check's @Intentionally* annotation. For ExemptionReason.IGNORE_JAVA_INTEROP, add a description.

An exemption leaves the declaration visible to Java. To hide it, use @JvmSynthetic.

See Exemptions and internal API for more details about exemption reasons.

See also​