Milestone Beta Release Adds Module Information to Default Standard Library Artifacts, Enabling Easy Use with the jlink Tool
The upcoming Kotlin 1.4 release from JetBrains has reached its final milestone preview stage with version 1.4 M3. This update introduces significant improvements to the Kotlin standard library to better support Java modularity, which is a crucial feature for modern JVM applications.
One of the key updates in Kotlin 1.4 M3 is the inclusion of module-info descriptors in the standard library artifacts. This change allows Kotlin developers to leverage Java 9’s module system more effectively. The module-info.java files enable easier integration with the jlink
tool, which is used to generate custom Java runtime images. These images include only the platform modules necessary for the application, streamlining the deployment process and reducing the size of the runtime environment.
Previously, using jlink
with Kotlin’s standard library required a more complex setup, making it challenging for developers to create modular applications. With the addition of module-info descriptors, this process is now simplified. Android developers, in particular, must use Android Gradle Plugin version 3.2 or higher to process jars with module-info files effectively.
In addition to the module-info improvements, Kotlin 1.4 M3 introduces several other enhancements:
- Functional Interfaces: The standard library now includes functional interfaces, which are useful for functional programming patterns and lambda expressions.
- Collection Operations: New operations for collections have been added, addressing practical scenarios encountered in real-life coding tasks.
- Changes to Suspended Functions: The behavior of suspended functions annotated with
@Throws
has been refined. Specifically, if asuspend fun
is annotated with@Throws
, developers must includeCancellationException::class
as a parameter of the@Throws
annotation. - Deprecations: Certain functions related to floating-point arrays have been deprecated, signaling shifts in recommended practices or improvements in library design.
The Kotlin 1.4 M3 milestone was unveiled on July 6, following the M2 milestone release in June. Developers interested in exploring the new features can use the Kotlin Playground for an online trial. Those using IntelliJ IDEA or Android Studio can update their Kotlin plugin to version 1.4-M3. The next step will be the release candidate for Kotlin 1.4, which will finalize the updates and prepare for the official release.