You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
> This document doesn't cover all of the features of the Early Access Preview (EAP) release,
9
8
> but it highlights some major improvements.
10
9
>
11
10
> See the full list of changes in the [GitHub changelog](https://github.com/JetBrains/kotlin/releases/tag/v%kotlinEapVersion%).
12
11
>
13
12
{style="note"}
14
13
15
-
-->
14
+
The Kotlin %kotlinEapVersion% release is out! Here are some details of this EAP release:
16
15
17
-
The Kotlin %kotlinEapVersion% release is out! See the full list of changes in the [GitHub changelog](https://github.com/JetBrains/kotlin/releases/tag/v%kotlinEapVersion%).
16
+
***Kotlin compiler plugins**: [Lombok is Alpha](#lombok-is-now-alpha) and [improved JPA support in the `kotlin.plugin.jpa` plugin](#improved-jpa-support-in-the-kotlin-plugin-jpa-plugin)
17
+
***Kotlin/Native**: [New interoperability mode for C and Objective-C libraries](#new-interoperability-mode-for-c-or-objective-c-libraries) and [concurrent marking in the garbage collector is enabled by default](#default-concurrent-marking-in-garbage-collector)
18
+
***Gradle**: [Compatibility with Gradle 9.3.0](#compatibility-with-gradle-9-3-0) and [Kotlin/JVM compilation uses BTA by default](#kotlin-jvm-compilation-uses-build-tools-api-by-default)
19
+
***Maven**: [Simplified setup for Kotlin projects](#maven-simplified-setup-for-kotlin-projects)
20
+
***Standard library**: [New API for creating immutable copies of `Map.Entry`](#standard-library-new-api-for-creating-immutable-copies-of-map-entry)
18
21
19
22
> For information about the Kotlin release cycle, see [Kotlin release process](releases.md).
20
23
>
@@ -26,4 +29,207 @@ The Kotlin plugins that support %kotlinEapVersion% are bundled in the latest ver
26
29
You don't need to update the Kotlin plugin in your IDE.
27
30
All you need to do is [change the Kotlin version](configure-build-for-eap.md) to %kotlinEapVersion% in your build scripts.
28
31
29
-
See [Update to a new release](releases.md#update-to-a-new-kotlin-version) for details.
32
+
See [Update to a new release](releases.md#update-to-a-new-kotlin-version) for details.
33
+
34
+
## Kotlin compiler plugins
35
+
36
+
Kotlin %kotlinEapVersion% brings important updates to the Lombok and `kotlin.plugin.jpa` compiler plugins.
37
+
38
+
### Lombok is now Alpha
39
+
<primary-labelref="alpha"/>
40
+
41
+
Kotlin 1.5.20 introduced the experimental [Lombok compiler plugin](lombok.md), which lets you generate and use [Java's Lombok declarations](https://projectlombok.org/) in modules that mix Kotlin and Java code.
42
+
43
+
In %kotlinEapVersion%, the Lombok compiler plugin is promoted to [Alpha](components-stability.md#stability-levels-explained) because we plan to productize this functionality, but it's still under development.
44
+
45
+
### Improved JPA support in the `kotlin.plugin.jpa` plugin
46
+
47
+
The `kotlin.plugin.jpa` plugin now automatically applies the [`all-open`](all-open-plugin.md) compiler plugin with the newly added built-in JPA preset,
48
+
in addition to the existing [`no-arg`](no-arg-plugin.md) support.
49
+
50
+
Previously, using `kotlin("plugin.jpa")` enabled only the `no-arg` plugin with JPA presets. And when working with JPA entities, you had to explicitly apply and configure the `all-open` plugin to make JPA entity classes `open`.
51
+
52
+
Starting with Kotlin %kotlinEapVersion%:
53
+
54
+
* The `all-open` compiler plugin provides a JPA preset.
55
+
* The Gradle `org.jetbrains.kotlin.plugin.jpa` plugin automatically applies the `org.jetbrains.kotlin.plugin.all-open` plugin with the JPA preset enabled.
56
+
* The [Maven JPA setup](no-arg-plugin.md#jpa-support) enables `all-open` with the JPA preset by default.
57
+
* The Maven dependency `org.jetbrains.kotlin:kotlin-maven-noarg` now implicitly includes `org.jetbrains.kotlin:kotlin-maven-allopen`, so you no longer need to add it explicitly in the `<plugin><dependencies>` block.
58
+
59
+
As a result, JPA entities annotated with the following annotations
60
+
are automatically treated as `open` and receive no-argument constructors without additional configuration:
61
+
62
+
*`javax.persistence.Entity`
63
+
*`javax.persistence.Embeddable`
64
+
*`javax.persistence.MappedSuperclass`
65
+
*`jakarta.persistence.Entity`
66
+
*`jakarta.persistence.Embeddable`
67
+
*`jakarta.persistence.MappedSuperclass`
68
+
69
+
70
+
This change simplifies build configuration and improves the out-of-the-box experience when using Kotlin with JPA frameworks.
71
+
72
+
## Kotlin/Native
73
+
74
+
Kotlin %kotlinEapVersion% introduces a new experimental interoperability mode for C and Objective-C libraries
75
+
and enables concurrent marking in the garbage collector by default in the Kotlin 2.3.20-Beta releases.
76
+
77
+
### New interoperability mode for C or Objective-C libraries
78
+
<primary-labelref="experimental-opt-in"/>
79
+
80
+
If you use C or Objective-C libraries in your Kotlin Multiplatform libraries or applications, we invite you to test the new interoperability mode and share the results.
81
+
82
+
In general, Kotlin/Native enables importing C and Objective-C libraries into Kotlin. However, for Kotlin Multiplatform libraries, this functionality is currently [affected](native-lib-import-stability.md#stability-of-c-and-objective-c-library-import) by the KMP compatibility issues with older compiler versions.
83
+
84
+
In other words, if you publish a Kotlin Multiplatform library compiled with one Kotlin version, importing C or Objective-C libraries might make it impossible to use that Kotlin library in projects with an earlier Kotlin version.
85
+
86
+
To address this and other issues, the Kotlin team has been revising the interoperability mechanism used under the hood. Starting with Kotlin 2.3.20-Beta1, you can try the new mode through a compiler option.
87
+
88
+
#### How to try
89
+
90
+
1. In your Gradle build file, check whether you have a `cinterops {}` block or a `pod()` dependency. If these are present, your project uses C or Objective-C libraries.
91
+
2. Ensure your project uses `2.3.20-Beta1` or a later version.
92
+
3. In the same build file, add the `-Xccall-mode` compiler option to the cinterop tool invocation:
4. Buildand test your project as usual by running unit tests, the app, and so on.
107
+
108
+
You can also use the `--continue` option to allow Gradle to continue executing tasks even after failures, helping to find more problems at once.
109
+
110
+
>Do**not** publish libraries compiled with the new interoperability mode yet, as it's still [Experimental](components-stability.md#stability-levels-explained).
111
+
>
112
+
{style="warning"}
113
+
114
+
#### Report your results
115
+
116
+
The new interoperability mode is supposed to be a drop-in replacement in most cases.
117
+
We're planning to eventually enable it by default. But to achieve that, we need to ensure it works as well as possible and test it on a wide range of projects, because:
118
+
119
+
*SomeCandObjective-C declarations aren't supported yet in the new mode (mostly because they conflict with the compatibility issues). We'd like to better understand the real-world impact of thisand prioritize future steps accordingly.
120
+
*There may be bugs or things we didn't consider. Testing languages with numerous interacting features is challenging, and testing the interaction between languages (each with a unique set of features) is even more so.
121
+
122
+
Help us examine real-world projects and identify challenging cases.
123
+
Whether you encounter any issues or not, share your results in the comments to [this YouTrack issue](https://youtrack.jetbrains.com/issue/KT-83218).
124
+
125
+
### Default concurrent marking in garbage collector
126
+
<primary-label ref="experimental-opt-in"/>
127
+
128
+
Kotlin 2.0.20 [introduced experimental support](whatsnew2020.md#concurrent-marking-in-garbage-collector) for CMS, also known as concurrent mark and sweep in the garbage collector (GC). Since then, the Kotlin team has fixed several critical and major problems and already uses CMS in [Swift export](native-swift-export.md) in its default setup.
129
+
130
+
As the next step, we're enabling CMS by default for all projects in both Kotlin2.3.20-Beta1andBeta2 releases to gather more feedback and ensure we've discovered all the issues.
131
+
132
+
Compared to the current default parallel mark concurrent sweep (PMCS) setup in the garbage collector, where application threads must be paused while the GC marks objects in the heap, CMS allows the marking phase to run concurrently with application threads.
133
+
134
+
This greatly affects the duration of GC pauses and app responsiveness, which is important for the performance of latency-critical applications. CMS has already shown its effectiveness by significantly improving benchmarks on UI applications built with [Compose Multiplatform](https://blog.jetbrains.com/kotlin/2024/10/compose-multiplatform-1-7-0-released/#performance-improvements-on-ios).
135
+
136
+
#### Leave feedback
137
+
Although CMS GC is the default in this release, it's still [Experimental](components-stability.md#stability-levels-explained). In some cases, it may lead to runtime crashes, throughput issues, or increased memory consumption.
138
+
139
+
Thisis why we're taking a cautious approach here: we're enabling CMS by default only inBeta releases to gather additional feedback. It will be rolled back to PMCSinKotlin2.3.20-RCandfinal releases.
140
+
141
+
If you observe regressions, switch to PMCS manually. Todo that, set the following [binary option](native-binary-options.md) in your `gradle.properties` file:
142
+
143
+
```none
144
+
kotlin.native.binary.gc=pmcs
145
+
```
146
+
147
+
Report any problems to our issue tracker [YouTrack](https://kotl.in/issue).
148
+
149
+
## Gradle
150
+
151
+
Kotlin %kotlinEapVersion% is compatible with new versions of Gradle and includes changes to Kotlin/JVM compilation in the Kotlin Gradle plugin.
152
+
153
+
### Compatibility with Gradle 9.3.0
154
+
155
+
Kotlin %kotlinEapVersion% is fully compatible with Gradle 7.6.3 through 9.3.0. You can also use Gradle versions up to the latest Gradle release. However, be aware that doing so may result in deprecation warnings, and some new Gradle features might not work.
156
+
157
+
### Kotlin/JVM compilation uses Build tools API by default
158
+
<primary-labelref="experimental-general"/>
159
+
160
+
In Kotlin %kotlinEapVersion%, Kotlin/JVM compilation in the Kotlin Gradle plugin uses the [Build tools API](build-tools-api.md)
161
+
(BTA) by default. This change in the internal compilation infrastructure enables faster development of build tool support for the Kotlin compiler.
162
+
163
+
If you notice any issues, share your feedback in our [issue tracker](https://youtrack.jetbrains.com/newIssue?project=KT&summary=Kotlin+Gradle+plugin+BTA+migration+issue&description=Describe+the+problem+you+encountered+here.&c=tag+kgp-bta-migration).
164
+
165
+
## Maven: Simplified setup for Kotlin projects
166
+
167
+
Kotlin %kotlinEapVersion% makes it easier to set up Kotlin in Maven projects. Now Kotlin supports automatic configuration of source roots and Kotlin's standard library.
168
+
169
+
With the new configuration, when you create a new Kotlin project with the Maven build system or introduce Kotlin to your existing Java Maven project, you don't need to manually create source roots or add the `kotlin-stdlib` dependency in your POM build file.
170
+
171
+
### How to enable
172
+
173
+
In your `pom.xml` file, add `<extensions>true</extensions>` to the `<build><plugins>` section of the Kotlin Maven plugin:
174
+
175
+
```xml
176
+
<build>
177
+
<plugins>
178
+
<plugin>
179
+
<groupId>org.jetbrains.kotlin</groupId>
180
+
<artifactId>kotlin-maven-plugin</artifactId>
181
+
<version>%kotlinEapVersion%</version>
182
+
<extensions>true</extensions> <!-- Add this extension -->
183
+
</plugin>
184
+
</plugins>
185
+
</build>
186
+
```
187
+
188
+
The new extension automatically:
189
+
190
+
* Creates `src/main/kotlin` and `src/test/kotlin` directories without changing existing Kotlin or Java source roots.
191
+
* Adds the `kotlin-stdlib` dependency unless it's already defined.
192
+
193
+
You can also opt out of the automatic addition of Kotlin's standard library. For that, add the following `<properties>` section to the Kotlin Maven plugin entry:
For more information on Maven configuration in Kotlin projects, see [Configure a Maven project](maven-configure-project.md).
210
+
211
+
## Standard library: New API for creating immutable copies of `Map.Entry`
212
+
<primary-labelref="experimental-opt-in"/>
213
+
214
+
Kotlin %kotlinEapVersion% introduces the `Map.Entry.copy()` extension function for creating an immutable copy of a [`Map.Entry`](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-map/-entry/).
215
+
This function allows you to reuse entries obtained from [`Map.entries`](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-map/entries.html) after modifying the map by copying them first.
216
+
217
+
`Map.Entry.copy()` is [Experimental](components-stability.md#stability-levels-explained). To opt in, use the `@OptIn(ExperimentalStdlibApi::class)` annotation or the compiler option `-opt-in=kotlin.ExperimentalStdlibApi`.
218
+
219
+
Here's an example of using `Map.Entry.copy()` to remove entries from a mutable map:
220
+
221
+
```kotlin
222
+
@OptIn(ExperimentalStdlibApi::class)
223
+
funmain() {
224
+
val map =mutableMapOf(1 to 1, 2 to 2, 3 to 3, 4 to 4)
0 commit comments