Skip to content
Back to skills

Kotlin Knowledge Patch

ASecurity

Kotlin

  • 25 stars
  • 0 votes
  • 0 copies
  • 15 views
  • Added May 27, 2026
developmentjavascripttypescriptjavaswiftkotlintestingdebuggingapi

Works with

  • api

Security analysis

A100/100

Pro scans all 10 files and shows the line behind each finding

Scanned December 1, 2026

npx -y skills add Nevaberry/nevaberry-plugins --skill kotlin-knowledge-patch --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Kotlin Knowledge Patch?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Kotlin Knowledge Patch
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/nevaberry-kotlin-knowledge-patch/badge)](https://www.skillsdirectory.com/skills/nevaberry-kotlin-knowledge-patch)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: kotlin-knowledge-patch
description: Kotlin
version: "2.4.21"
license: MIT
metadata:
  author: Nevaberry
---


# Kotlin knowledge patch

Load this skill for Kotlin language and compiler migrations, Gradle and Maven
configuration, multiplatform interop, Compose, and ecosystem API changes.
Use the topic references for complete conditions, examples, and release attribution.

## Reference index

| Reference | Topics |
| --- | --- |
| [Language and compiler](references/language-and-compiler.md) | Context parameters, backing fields, inference, contracts, diagnostics, Analysis API |
| [JVM and build tooling](references/jvm-and-build-tooling.md) | Java interop, metadata, reflection, scripting, Gradle, Maven, ABI validation, Build Tools API |
| [Multiplatform and Native](references/multiplatform-and-native.md) | Source sets, dependencies, Apple targets, allocation, cinterop, Swift export |
| [JavaScript and Wasm](references/javascript-and-wasm.md) | Exports, TypeScript, npm, browser tests, debugging, exceptions, WASI |
| [Standard library](references/standard-library.md) | UUIDs, time, atomics, collections, Base64, assertions |
| [Compose Multiplatform](references/compose-multiplatform.md) | Compiler, dependencies, navigation, resources, iOS, desktop, web, UI tests, Hot Reload |
| [Ecosystem libraries and tooling](references/ecosystem-libraries.md) | Serialization, coroutines, Ktor, Exposed, Koog, IDEs, Kotlin Toolchain |

## Breaking changes and deprecations

### Context receivers and overloads

Kotlin 2.3.20 removes experimental context receivers; migrate declarations to
context parameters. A context parameter no longer makes an overload more specific
in 2.3.20. Calls can become ambiguous when overloads differ only by context
parameters and the context is available; give the overloads distinct names where needed.
Context parameters are stable at language version 2.4 without the preview flag.

### Gradle compiler options and Android integration

Reads and writes through `kotlinOptions` properties produce errors, including in
task configuration. Migrate to `compilerOptions`, for example
`compilerOptions.jvmTarget.set(JvmTarget.JVM_25)` with
`org.jetbrains.kotlin.gradle.dsl.JvmTarget` imported.

On AGP 9, use built-in Kotlin for Android-only modules and remove
`org.jetbrains.kotlin.android`. For multiplatform Android libraries, apply
`com.android.kotlin.multiplatform.library` and change
`kotlin { androidTarget { … } }` to `kotlin { android { … } }`.
Stay on AGP 8.x with Kotlin 2.3.10 to retain `androidTarget`.

### Source registration and test dependencies

`KotlinCompileTool.setSource(...)` replaces configured sources; `source(...)`
appends them. Register resource directories through `KotlinSourceSet.resources`
because `KotlinCompilationOutput.resourcesDirProvider` produces a deprecation error.
Register generated code on a `KotlinSourceSet` through experimental `generatedKotlin`;
build logic reading handwritten and generated files should use `sourceSet.allKotlinSources`.
Replace `testApi()` with `testImplementation()`, or use
`commonTest.dependencies { implementation(...) }` instead of `api(...)`.

### Removed and deprecated build switches

Remove `kotlin.incremental.classpath.snapshot.enabled`,
`kotlin.compiler.preciseCompilationResultsBackup`, and
`kotlin.compiler.keepIncrementalCompilationCachesInMemory` from Gradle properties.
The `KotlinCompile.classpathSnapshotProperties.useClasspathSnapshot` and
`KotlinCompile.classpathSnapshotProperties.classpath` task properties are removed.
Gradle warns on `kapt.use.k2=false`; remove it to use the default K2 implementation.
Applying `kotlin-android-extensions` fails at configuration time.
Kotlin 2.3.0 removes Ant build support; migrate those builds to Gradle or Maven.

### JVM defaults, reflection, and Java properties

Stable `-jvm-default` replaces `-Xjvm-default` and defaults to `enable`, emitting
default methods with compatibility bridges and `DefaultImpls`.
If Java implementations encounter conflicting defaults from unrelated interfaces,
use `-jvm-default=disable`; `-jvm-default=no-compatibility` emits only default methods.
Annotated JVM lambdas use `invokedynamic` by default. Use
`-Xindy-allow-annotated-lambdas=false` if reflection depends on generated-class annotations.
Through a Java subclass or mapped Java type, synthetic property access can fail
when the getter was declared in Kotlin; call the getter, such as `obj.getName()`.
The Java synthetic property-reference
experiment was revoked; use `Person::getName` where a function reference is accepted.

### Native builds and Apple integration

Remove `kotlin.native.enableKlibsCrossCompilation=true`: supported hosts can
produce publishable KLIBs by default. Use a Mac for cinterop dependencies in the
library or dependent modules, CocoaPods integration, and final Darwin binaries or tests.
Replace deprecated `kotlin.native.cacheKind` with `disableNativeCache` on the
affected binary, supplying a Kotlin version and reason, with an optional issue URI.
On Kotlin 2.3.20 or later, pass `-Xccall-mode direct` to cinterop to try the
experimental C and Objective-C mode. Keep libraries built in this mode for local testing.

### Wasm initialization and build configuration

Wasm modules initialize during instantiation; remove post-instantiation calls to
`_initialize()`. Review `@EagerInitialization` because initializer code can run
before module initialization finishes.
At Kotlin 2.3.0, both Wasm targets enable `KClass.qualifiedName` by default;
remove `-Xwasm-kclass-fqn`. `wasmWasi` uses the new exception-handling instructions
by default and needs a supporting runtime. Enable them on `wasmJs` with
`-Xwasm-use-new-exception-proposal`.
Move D8 and Binaryen imports from `org.jetbrains.kotlin.gradle.targets.js` to
`org.jetbrains.kotlin.gradle.targets.wasm`.

### Compose dependencies and previews

Compose Multiplatform deprecated Gradle aliases such as `compose.ui` in 1.10.
Use coordinates from the deprecation notices in a version catalog, for example
`org.jetbrains.compose.ui:ui:1.10.3`. In `commonMain`, use
`androidx.compose.ui.tooling.preview.Preview` instead of the deprecated
`org.jetbrains.compose.ui.tooling.preview.Preview` or
`androidx.compose.desktop.ui.tooling.preview.Preview` imports.
Pass `PopupProperties` to `Popup`; overloads without it produce a deprecation error.

### Compose navigation, resources, and iOS configuration

Replace `PredictiveBackHandler` with `NavigationBackHandler` from
`org.jetbrains.androidx.navigationevent:navigationevent-compose`. Pass remembered
event state, handle cancellation and completion separately, and read progress from
the in-progress transition. On web, migrate `window.bindToNavigation(navController)`
to the suspending `navController.bindToBrowserNavigation()` extension.

Set `CADisableMinimumFrameDurationOnPhone` to Boolean `true` in the host app's
`Info.plist`; Compose crashes if it is missing or false. The check can be bypassed
with `enforceStrictPlistSanityCheck = false` in `ComposeUIViewController` configuration.
With AGP 8.8.0 or newer, enable Android resources in `androidLibrary` to package
generated Compose assets; leaving them disabled can cause `MissingResourceException`.

### Compose test scheduling

On non-Android targets, migrate deprecated `runComposeUiTest`,
`runSkikoComposeUiTest`, and `runDesktopComposeUiTest` to their v2 counterparts.
They queue coroutine work on `StandardTestDispatcher` by default; `effectContext`
provides a composition coroutine context such as a dispatcher or motion duration scale.
Idle checks can report idle while composition coroutines are suspended in `delay()`.
After the effect starts, advance virtual time explicitly. In 1.8.2, advancing the
test clock triggers recomposition, layout, and drawing only when the advance reaches
a virtual frame boundary. Test frames are 16 ms apart.

## Language and library quick reference

### Contexts, properties, and destructuring

Declare context parameters on the whole property and use explicit computed
accessors; contextual properties disallow backing fields, initializers, and delegation.
Explicit backing fields are stable at language version 2.4 without the preview flag.
They can have a more specific type than the public property; within the field's
private scope, property access is smart-cast to the field type.

Use `-Xname-based-destructuring=only-syntax` for explicit property matching with
existing parentheses kept positional, `name-mismatch` to warn when positional names
differ from data-class properties,
or `complete` for short-form parentheses matched by name and square brackets by position.
With `-Xcollection-literals`, literals can resolve to a companion-block `of` operator;
the fallback to `List` applies only when the expected type is a supertype of `List`.

### Compiler warnings and discarded results

Use `-Xwarning-level=UNCHECKED_CAST:error`, `:disabled`, or `:warning` to control
one diagnostic. `:warning` emits it even under `-Werror` or `-nowarn` and can enable
an individual `-Wextra` check.
Enable the experimental unused-result checker with `-Xreturn-value-checker=check`
for marked APIs, or `-Xreturn-value-checker=full` to treat every compiled file as marked.
Use `@MustUseReturnValues`, `@file:MustUseReturnValues`, and `@IgnorableReturnValue`
to mark APIs or exempt functions. `val _ = computeValue()` explicitly discards a result.

### UUIDs, clocks, atomics, and collections

Code using the stabilized `kotlin.uuid.Uuid` API can drop its `ExperimentalUuidApi` opt-in.
`Uuid.parseOrNull(text)` accepts both supported formats and returns `null` for invalid input.
`Uuid.generateV7()` generates monotonically ordered version 7 UUIDs;
`Uuid.generateV7NonMonotonicAt(Instant.fromEpochMilliseconds(1577836800000))`
can generate out-of-order IDs for the same timestamp.
`kotlin.time.Clock` and `kotlin.time.Instant` are stable in Kotlin 2.3.0;
remove `ExperimentalTime` where it was used only for those APIs.

Common atomics in `kotlin.concurrent.atomics` require `ExperimentalAtomicApi`.
On JVM, `asJavaAtomic()` and `asKotlinAtomic()` expose the same atomic object.
`allEqual()` and `allDistinct()` test equality or pairwise distinctness;
`allEqualBy { ... }` and `allDistinctBy { ... }` compare selected keys.

## Build, interop, and ecosystem quick reference

### ABI validation and build integration

The experimental Gradle ABI validator compares library ABI against a reference dump.
Use `checkKotlinAbi`, `updateKotlinAbi`, and `internalDumpKotlinAbi` in place of
`checkLegacyAbi`, `updateLegacyAbi`, and `dumpLegacyAbi`.
The old names still work in Kotlin 2.3.20, where enabling validation also makes
Gradle's `check` run `checkKotlinAbi` automatically.
For multiplatform validation, `klib { keepUnsupportedTargets = false }` fails on
targets the host cannot build instead of inferring their changes from supported targets.

### Swift and JavaScript export

Experimental Swift export in Kotlin 2.2.20 uses
`./gradlew :shared:embedSwiftExportForXcode` in the directly integrated Xcode Run Script,
replacing `embedAndSignAppleFrameworkForXcode`; use the shared module's Gradle path.
`swiftExport.export(...)` exposes a dependency as its own Swift module.
Generic type parameters are erased to upper bounds, and function values cross
the boundary from Swift to Kotlin only.

Enable `-Xenable-suspend-function-exporting` for Kotlin/JS `@JsExport` suspend functions.
For TypeScript implementations of exported Kotlin interfaces, in `js { }` call
`generateTypeScriptDefinitions()` and add `-Xenable-implementing-interfaces-from-typescript`
to `compilerOptions.freeCompilerArgs`.
Implement `readonly [Interface.Symbol] = true`; delegate to `Interface.DefaultImpls` if needed.

### Serialization and coroutine behavior

In kotlinx.serialization 1.10.0, encoding throws `SerializationException` when a
transformed property name collides with the class discriminator; decoding permits
the conflicting key in both open and sealed polymorphic hierarchies.
Use kotlinx.serialization 1.9.0 with Kotlin 2.2 or later for `kotlin.time.Instant`.
The default serializer uses its string representation; use
`@Serializable(with = InstantComponentSerializer::class)` on a property for components.
Kotlinx.coroutines 1.10.2 fixes suspending `flow.stateIn(scope)` hangs when upstream
completes without emitting or the scope was already cancelled.
Since kotlinx.coroutines 1.8.0, `runTest` defaults to 60 seconds; set
`-Dkotlinx.coroutines.test.default_timeout=10s` on the test JVM to change the suite default.

Files in this skill

  • SKILL.md7.1 KB
  • references/build-tooling.md1.2 KB
  • references/compiler-features.md2.7 KB
  • references/compose-multiplatform.md1022 B
  • references/context-parameters.md1.5 KB
  • references/ecosystem-updates.md1.7 KB
  • references/jvm-interop.md1.1 KB
  • references/language-features.md2.8 KB
  • references/stdlib-apis.md1.7 KB
  • references/type-system.md2 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.