Kotlin 1.8.0 version has been officially released, the following are some main contents of this version update:

New experimental feature for the JVM: Recursively copy or delete directory contents

Kotlin 1.8.0 is java.nio.file.Path Two new extension functions are introduced:copyToRecursively() with deleteRecursively()which allow you to recursively:

  • Copy a directory and its contents to another destination
  • delete a directory and its contents

These functions can be very useful as part of the backup process.

for java.nio.file.path These new functions for are experimental.To use them, you need to opt-in @OptIn(kotlin.io.path.ExperimentalPathApi::class) or @kotlin.io.path.ExperimentalPathApi.Alternatively, you can use the compiler option -opt-in=kotlin.io.path.ExperimentalPathApi.

Improved performance of kotlin-reflect

use kotlin-reflect The fact that is now compiled with JVM target 1.8, we migrated the internal caching mechanism to Java’s ClassValue.Previously we only cached KClassbut now we also cache the KType with KDeclarationContainer.These changes make calling typeOf() performance has been significantly improved.

Added -Xdebug compiler option for better debugging experience

Kotlin 1.8.0 adds a new -Xdebug A compiler option that disables optimizations for a better debugging experience. Currently, this option disables the “optimized” functionality of coroutines. In the future, when we add more optimizations, this option will disable them as well.

kotlin-stdlib-jdk7 with kotlin-stdlib-jdk8 merged into kotlin-stdlib

In Kotlin 1.8.0, the standard library (kotlin-stdlib,kotlin-reflect with kotlin-script-*) was compiled with JVM target 1.8. Previously, the standard library was compiled with JVM target 1.6.

Kotlin 1.8.0 no longer supports JVM targets 1.6 and 1.7.Therefore, you no longer need to declare separately in the build script kotlin-stdlib-jdk7 with kotlin-stdlib-jdk8as the contents of these artifacts have been merged into the kotlin-stdlib.

Improved Objective-C/Swift interoperability

To make Kotlin more interoperable with Objective-C and Swift, 1.8.0 adds three new annotations:

  • @ObjCNameAllows you to specify a more idiomatic name in Swift or Objective-C instead of renaming the Kotlin declaration.
  • @HiddenFromObjCAllows you to hide a Kotlin declaration from Objective-C
  • @ShouldRefineInSwift Useful for replacing Kotlin declarations with wrappers written in Swift

Compatible with Gradle 7.3

Kotlin 1.8.0 fully supports Gradle 7.2 and 7.3 versions, this version brings many changes:

  • Expose Kotlin compiler options as Gradle lazy properties
  • Increased minimum supported version
  • Ability to disable fallback strategies for Kotlin daemons
  • Mandatory check for equality of JVM target compatibility for related Kotlin and Java compilation tasks

More details can be viewed: https://kotlinlang.org/docs/whatsnew18.html

#Kotlin #released #improving #performance #Swift #interoperability

Leave a Comment

Your email address will not be published. Required fields are marked *