Kotlin 1.5.20 advances Java interoperability, helps to speed things up

Kotlin 1.5.20 advances Java interoperability, helps to speed things up

JetBrains’ programming language Kotlin is available in version 1.5.20, and though it is just a small version step, the update comes with notable improvements for developers who like their Kotlin with a side of Java.

In order to maintain null safety when working with both languages, Kotlin’s compiler learned to read the nullness annotations used in the JSpecify project, which teams can use to set default nullability amongst other things. Mismatches with the provided information will be reported as warnings, though there’s a strict mode available as well, interpreting them as errors.

Kotlin 1.5.20 by default compiles string concatenations into dynamic invocations when JVM 9 or newer is set as the target. Devs preferring the old behaviour can still use it by adding the compiler option -Xstring-concat=inline.

The update also includes an experimental plugin for working with methods generated by the Project Lombok library. Right now, it is said to handle @With, @Data, @Getter, @Setter, @Value, and annotations for creating constructors used in Java sources. Devs that would love to see the @Builder annotation making that list as well should consider voting the corresponding issue in YouTrack up. Currently there are no immediate plans to support it, but JetBrains is known to adjust its roadmap if there’s demand.

Thanks to some unification work, Kotlin/Native and Kotlin/JS users can get numeric representation for any Unicode digit by using Char.digitToInt(), while Char.isLowerCase() and Char.isUpperCase() now consider both the general category and Other_Uppercase/Other_Lowercase Unicode properties across platforms. 

Once updated to the latest release, the Kotlin/Native compiler can be set to export documentation comments to Objective-C or Swift headers using the -Xexport-kdoc compiler option. It is also meant to perform better when using Array.copyInto() inside one array. 

Looking into Kotlin’s Gradle plugin, the kotlin.parallel.tasks.in.project build property has been deprecated in favour of the --parallel execution flag and there’s an experimental feature for caching the classloaders of annotation processors in kapt.

Details on the changes can be found in the Kotlin documentation.