Kotlin beta previews support for coroutine stack trace recovery

Kotlin beta previews support for coroutine stack trace recovery

Kotlin 2.4.20-Beta2 also brings Wasm changes, new Swift export features, a DSL for browser testing, and the debut of the Kotlin compiler native image. JetBrains has released Kotlin 2.4.20-Beta2, an update to the company’s multiplatform programming language that has emerged with capabilities ranging from the Wasmtime runtime to JavaScript functions and Swift accommodations. Kotlin 2.4.20-Beta2 was released July 2. Among the new capabilities and improvements, the new release changes how Kotlin/Wasm handles top-level require() calls in @JsFun declarations, aligns companion object initialization order with JVM behavior, and supports Wasmtime as a runtime for thewasmWasi target in the Kotlin Gradle plugin. Kotlin/Wasm now initializes superclass companion objects before subclass companion objects, matching the JVM behavior. Previously, the initialization could be reversed, leading to inconsistent behavior across platforms. Kotlin 2.4.20-Beta2 also introduces cross-language inheritance support to Swift export. A common use case for this feature is the reverse import pattern, where developers define a contract in Kotlin and provide platform-specific implementations on the Swift side. And for Kotlin/JS, Kotlin 2.4.20-Beta2 introduces an experimental DSL for browser testing and support for exporting suspend lambdas as JavaScript async functions. Previously, there was no way to export declarations containing suspend lambdas from Kotlin/JS libraries. Now, the Kotlin compiler automatically handles the bridging between Kotlin’s suspend functions and native JavaScript’s async/await model. This is useful for mixed Kotlin/TypeScript codebases, JetBrains said. Kotlin 2.4.20-Beta2 introduces support for coroutine stack trace recovery, with the addition of the StackTraceRecoverable interface to the standard library. This feature, currently experimental, improves integration with the kotlinx.coroutines library because it allows developers to create new exception instances for stack trace recovery without adding a dependency on kotlinx.coroutines, according to JetBrains. Stack trace recovery helps with debugging when one coroutine throws an exception, and another rethrows it. It lets developers see where the exception originates and where another coroutine rethrows it. Also experimental are four new functions that check collection elements for equality and uniqueness. The functions .allDistinct(), .allDistinctBy(), .allEqual(), and .allEqualBy() can be used on collections, sequences, and arrays, and compare elements using structural equality like other collection operations. Until these functions arrived in Kotlin 2.4.20-Beta2, checking whether collection elements were all distinct or all equal required using inefficient code patterns, JetBrains said. And Kotlin 2.4.20-Beta2 features the first release of the Kotlin compiler native image. The native image offers a drop-in replacement for the standard kotlinc command-line tool, while offering faster startup time and higher performance, JetBrains said. This feature is also experimental.

Original Source

Read the full article at Infoworld →

KhanList aggregates and links to publicly available news content. We do not host full articles from third-party sources. Always verify important information with original sources.