Kotlin 2.4.0 发布
摘要
Kotlin 2.4.0 已发布,包含稳定的上下文参数、显式后备字段、改进的多平台支持(包括将 Swift 包作为依赖项),以及与 Java 26 和 Gradle 9.5.0 的兼容性。
<p><a href="https://lobste.rs/s/4h8pnc/kotlin_2_4_0_released">评论</a></p>
查看缓存全文
缓存时间: 2026/06/03 17:47
# Kotlin 2.4.0 发布 | Kotlin 博客
来源:https://blog.jetbrains.com/kotlin/2026/06/kotlin-2-4-0-released/
Kotlin 标志 (https://blog.jetbrains.com/kotlin/) 由 JetBrains 开发的简洁多平台语言
发布 (https://blog.jetbrains.com/kotlin/category/releases/)
## Kotlin 2.4.0 发布
Kotlin 2.4.0 版本已发布!以下是主要亮点:
- **语言**:稳定的上下文参数、显式幕后字段以及注解使用处目标的多个特性。
- **标准库**:稳定支持 UUID API,并支持检查排序顺序。
- **Kotlin/JVM**:支持 Java 26,且默认启用注解元数据。
- **Kotlin/Native**:支持 Swift 包作为依赖项,Swift 导出更新,以及默认启用 CMS GC。
- **Kotlin/Wasm**:默认启用增量编译,并支持 WebAssembly Component Model。
- **Kotlin/JS**:支持值类导出,以及 JS 代码内联中的 ES2015 特性。
- **Gradle**:兼容 Gradle 9.5.0。
- **Maven**:Java 和 JVM 目标版本自动对齐。
- **Kotlin 编译器**:在 `.klib` 编译期间内联函数行为更加一致。
有关变更的完整列表,请参阅 Kotlin 2.4.0 新特性 (https://kotlinlang.org/docs/whatsnew24.html) 或 GitHub 上的发布说明 (https://github.com/JetBrains/kotlin/releases/tag/v2.4.0)。
## 如何安装 Kotlin 2.4.0
最新版本的 Kotlin 已包含在最新版本的 IntelliJ IDEA (https://www.jetbrains.com/idea/download/) 和 Android Studio (https://developer.android.com/studio) 中。
要更新到新版本的 Kotlin,请在构建脚本中将 Kotlin 版本 (https://kotlinlang.org/docs/releases.html#update-to-a-new-kotlin-version) 更改为 2.4.0。
如果你需要命令行编译器,请从 GitHub 发布页面 (https://github.com/JetBrains/kotlin/releases/tag/v2.4.0) 下载。
**如果遇到任何问题:**
- 在 Slack (https://app.slack.com/client/T09229ZC6) 上寻求帮助(获取邀请 (https://surveys.jetbrains.com/s3/kotlin-slack-sign-up))。
- 向我们的问题跟踪器 YouTrack (https://youtrack.jetbrains.com/issues/KT) 报告问题。
及时了解最新的 Kotlin 功能!填写本文底部的表单订阅接收 Kotlin 更新。⬇️
## 来自 YouTrack 的顶级问题报告者
Andreas Malik (https://youtrack.jetbrains.com/issues/?q=project:KT,%20KTIJ%20created:%202025-12-16%20..%20*%20created%20by:%20gamalik) (21 个问题),Ryan Nett (https://youtrack.jetbrains.com/issues/?q=project:KT,%20KTIJ%20created:%202025-12-16%20..%20*%20created%20by:%20rnett) (20 个问题),Julien Dramaix (https://youtrack.jetbrains.com/issues/?q=project:KT,%20KTIJ%20created:%202025-12-16%20..%20*%20created%20by:%20dramaix) (18 个问题),Youssef Shoaib (https://youtrack.jetbrains.com/issues/?q=project:KT,%20KTIJ%20created:%202025-12-16%20..%20*%20created%20by:%20kyay10) (17 个问题),Jinseong Jeon (https://youtrack.jetbrains.com/issues/?q=project:KT,%20KTIJ%20created:%202025-12-16%20..%20*%20created%20by:%20jsjeon) (14 个问题),Zac Sweers (https://youtrack.jetbrains.com/issues/?q=project:KT,%20KTIJ%20created:%202025-12-16%20..%20*%20created%20by:%20ZacSweers) (11 个问题),Ivan Canet (https://youtrack.jetbrains.com/issues/?q=project:KT,%20KTIJ%20created:%202025-12-16%20..%20*%20created%20by:%20clovisai) (10 个问题),Jose Enrique Estremadoyro Fort (https://youtrack.jetbrains.com/issues/?q=project:KT,%20KTIJ%20created:%202025-12-16%20..%20*%20created%20by:%20joseefort) (9 个问题),Łukasz Wasylkowski (https://youtrack.jetbrains.com/issues/?q=project:KT,%20KTIJ%20created:%202025-12-16%20..%20*%20created%20by:%20l.wasylkowski) (8 个问题),calebbrandt77 (https://youtrack.jetbrains.com/issues/?q=project:KT,%20KTIJ%20created:%202025-12-16%20..%20*%20created%20by:%20Caleb_Brandt) (8 个问题),Edoardo Luppi (https://youtrack.jetbrains.com/issues/?q=project:KT,%20KTIJ%20created:%202025-12-16%20..%20*%20created%20by:%20lppedd) (8 个问题),Vadim Shabanov (https://youtrack.jetbrains.com/issues/?q=project:KT,%20KTIJ%20created:%202025-12-16%20..%20*%20created%20by:%20vadim.shabanov) (7 个问题),Asapha (https://youtrack.jetbrains.com/issues/?q=project:KT,%20KTIJ%20created:%202025-12-16%20..%20*%20created%20by:%20azefsw) (6 个问题),Louis CAD (https://youtrack.jetbrains.com/issues/?q=project:KT,%20KTIJ%20created:%202025-12-16%20..%20*%20created%20by:%20louis.cad) (6 个问题),Niklas Baudy (https://youtrack.jetbrains.com/issues/?q=project:KT,%20KTIJ%20created:%202025-12-16%20..%20*%20created%20by:%20vanniktech) (6 个问题),Rick Clephas (https://youtrack.jetbrains.com/issues/?q=project:KT,%20KTIJ%20created:%202025-12-16%20..%20*%20created%20by:%20rickclephas) (6 个问题),rlnt (https://youtrack.jetbrains.com/issues/?q=project:KT,%20KTIJ%20created:%202025-12-16%20..%20*%20created%20by:%20rlnt) (5 个问题),marc (https://youtrack.jetbrains.com/issues/?q=project:KT,%20KTIJ%20created:%202025-12-16%20..%20*%20created%20by:%20marczeugs) (5 个问题),Victor Turansky (https://youtrack.jetbrains.com/issues/?q=project:KT,%20KTIJ%20created:%202025-12-16%20..%20*%20created%20by:%20Turansky) (5 个问题),以及 Dirk Lattermann (https://youtrack.jetbrains.com/issues/?q=project:KT,%20KTIJ%20created:%202025-12-16%20..%20*%20created%20by:%20dlatt) (5 个问题)。
## 外部贡献者
我们要感谢所有贡献者的拉取请求被纳入此版本:
AndreyBozhko (https://github.com/AndreyBozhko),ArseniySukhanov (https://github.com/ArseniySukhanov),bennyhuo (https://github.com/bennyhuo),BraisGabin (https://github.com/BraisGabin),dmaclach (https://github.com/dmaclach),kralliv (https://github.com/kralliv),loadkrnis (https://github.com/loadkrnis),migmacdev (https://github.com/migmacdev),NeonMika (https://github.com/NeonMika),nyksans (https://github.com/nyksans),oscarArismendi (https://github.com/oscarArismendi),rickclephas (https://github.com/rickclephas),stefanhaustein (https://github.com/stefanhaustein),Stream29 (https://github.com/Stream29),tcmulcahy (https://github.com/tcmulcahy),以及 ZacSweers (https://github.com/ZacSweers)。
## 特别感谢我们的 EAP Champions
- Alexander Nozik (https://x.com/noraltavir)
- Benoit Lubek (https://github.com/BoD)
- Bernd Prünster (https://github.com/JesusMcCloud)
- David Lopez (https://github.com/HagamosVideojuegos)
- Dayan Ruben (https://github.com/dayanruben)
- Florian Schreiber (https://github.com/molikuner)
- Ivan Canet (https://ivan.canet.dev/)
- Jake Wharton (https://jakewharton.com/)
- Johannes Svensson (https://www.linkedin.com/in/johannessvensson/)
- Łukasz Wasylkowski (https://www.linkedin.com/in/lukasz-wasylkowski/)
- Mohamed Rejeb (https://github.com/MohamedRejeb)
- Olaf Gottschalk (https://github.com/Zordid)
- Rick Clephas (https://github.com/rickclephas)
- Sechaba Mofokeng (https://github.com/msotho)
- Sergey Chernov (https://github.com/seregamorph)
- Sterling Albury (https://sterlingalbury.com/)
- Yang (https://github.com/ychescale9)
- Yuri Geronimus (https://www.linkedin.com/in/yuri-geronimus/)
- Zac Sweers (https://bsky.app/profile/zacsweers.dev)
## 延伸阅读
- Kotlin 2.4.0 新特性文档 (https://kotlinlang.org/docs/whatsnew24.html)
- Kotlin 2.4.0 兼容性指南 (https://kotlinlang.org/docs/compatibility-guide-24.html)
- Kotlin EAP Champions (https://blog.jetbrains.com/kotlin/2022/11/eap-champions/)
#### 订阅 Kotlin 博客更新
https://blog.jetbrains.com/kotlin/2026/06/kotlin-2-4-0-released/#
## 了解更多
相似文章
@googledevs: Android Studio Quail 2 现已稳定!带来更高生产力、更快调试和更智能的AI辅助…
Android Studio Quail 2 现已稳定,引入并行AI代理聊天、集成 LeakCanary 内存泄漏检测(分析速度提升5倍),以及由 Gemini 驱动的崩溃修复。
@AndroidDev: R8使Android上的Kotlin协程速度提升2倍 借助AGP 9.2.0,R8将优化大多数Atomic*FieldUpdater调用为Un…
AGP 9.2.0中的R8将Atomic*FieldUpdater调用优化为Unsafe变体,使Android上的Kotlin协程速度提升高达2倍。这显著提升了Jetpack Compose的性能。
@googledevs: 更少的上下文切换,更多的编码。最新的 Android Studio 更新带来了原生集成的内存分析、并…
Android Studio Quail 2 引入了原生集成的内存分析、并行聊天和上下文感知的崩溃修复,以减少开发者的上下文切换。
@rudrank: FoundationModelsKit 2.0.0 已发布!我在处理 OS 27 后,将可重用的部分从 Foundation Lab 中提取出来,并…
FoundationModelsKit 2.0.0 作为一个独立的 Swift 包发布,包含运行时检查、模式助手、令牌计数、对话历史记录以及用于构建应用和 CLI 的内置工具,这些工具基于 Apple 的 Foundation Models 框架。
@raydistributed: 我们刚刚发布了 Ray 2.56!这包括 - Ray Data 稳定性改进:减少对象存储溢出,自动 ba…
Ray 2.56 已发布,改进了 Ray Data、面向 LLM 的 Ray Serve、GPU 域感知放置组以及 Kubernetes 集成。