JDK 14 · 2020-03-17
JDK 14:Switch 表达式转正
Switch 表达式正式转正,record 与 instanceof 模式匹配进入预览;CMS GC、Pack200、Nashorn 相继移除。
16官方 JEP 数
2正式特性
3预览 / 孵化
3移除 / 弃用
代表特性HIGHLIGHTS
这些是这一版最值得记住的变化。状态标签区分「正式 / 预览 / 孵化 / 移除」——预览不等于稳定,迁移时要特别确认。
全部 JEP16
数据来自 OpenJDK 官方 Features 表。中文名称仅为主要特性的人工标注。
| JEP | 标题 | 状态 | 来源 |
|---|---|---|---|
| JEP 305 | Pattern Matching for instanceof (Preview) instanceof 模式匹配(预览) | 预览 | 官方 → |
| JEP 343 | Packaging Tool (Incubator) | — | 官方 → |
| JEP 345 | NUMA-Aware Memory Allocation for G1 | — | 官方 → |
| JEP 349 | JFR Event Streaming | — | 官方 → |
| JEP 352 | Non-Volatile Mapped Byte Buffers | — | 官方 → |
| JEP 358 | Helpful NullPointerExceptions Helpful NullPointerExceptions | 正式 | 官方 → |
| JEP 359 | Records (Preview) record(预览) | 预览 | 官方 → |
| JEP 361 | Switch Expressions (Standard) Switch 表达式转正 | 正式 | 官方 → |
| JEP 362 | Deprecate the Solaris and SPARC Ports 移除 CMS GC | 移除 | 官方 → |
| JEP 363 | Remove the Concurrent Mark Sweep (CMS) Garbage Collector | — | 官方 → |
| JEP 364 | ZGC on macOS | — | 官方 → |
| JEP 365 | ZGC on Windows | — | 官方 → |
| JEP 366 | Deprecate the ParallelScavenge + SerialOld GC Combination | — | 官方 → |
| JEP 367 | Remove the Pack200 Tools and API | — | 官方 → |
| JEP 368 | Text Blocks (Second Preview) 文本块(第二次预览) | 预览 | 官方 → |
| JEP 370 | Foreign-Memory Access API (Incubator) | — | 官方 → |
移除与弃用REMOVED
升级前先排查这些变化。移除项通常不会在编译期全部报错,运行时或工具链上才暴露。
- CMS GC(JEP 362)
- Pack200 工具与 API(JEP 363)
- Nashorn(JEP 367)
这一版的故事STORY
Java 14 是 record 的起点,也是旧技术集中退场的版本:CMS、Pack200、Nashorn 都在这里被移除。Helpful NPE 则是开发者最能直接感知的体验改进。
怎么用这一页:先读故事建立坐标,再扫一遍代表特性。如果你正在用这个版本,重点看「移除与弃用」;如果你在选型或面试,重点记住 2–3 个代表特性及其版本边界。