JDK 25 于 2025 年 9 月 16 日 发布,这是一个非常重要的版本,里程碑式。
JDK 25 是 LTS(长期支持版),至此为止,目前有 JDK8、JDK11、JDK17、JDK21 和 JDK 25 这四个长期支持版了。
JDK 21 共有 18 个新特性,这篇文章会挑选其中较为重要的一些新特性进行详细介绍:
- JEP 506: Scoped Values (作用域值)
- JEP 512: Compact Source Files and Instance Main Methods (紧凑源文件与实例主方法)
- JEP 519: Compact Object Headers (紧凑对象头)
- JEP 521: Generational Shenandoah (分代 Shenandoah GC)
- JEP 507: Primitive Types in Patterns, instanceof, and switch (模式匹配支持基本类型, 第三次预览)
- JEP 505: Structured Concurrency (结构化并发, 第五次预览)
- JEP 511: Module Import Declarations (模块导入声明)
- JEP 513: Flexible Constructor Bodies (灵活的构造函数体)
- JEP 508: Vector API (向量 API, 第十次孵化)

