Skip to main content

Java 15

核心总结

  • Text Blocks、ZGC、Shenandoah 转正,Nashorn/Solaris/SPARC 移除,Sealed Classes 首次预览。

升级关注

  • Nashorn 已移除,脚本场景迁移到 GraalJS 或其他引擎。
  • ZGC 和 Shenandoah 转正,但仍需按业务延迟/吞吐目标压测。

示例

Text Blocks 正式

String sql = """
select id, name
from users
where status = 'active'
""";

Sealed Classes Preview

// javac --enable-preview --release 15 Shape.java
sealed interface Shape permits Circle, Rect {}
final class Circle implements Shape {}
final class Rect implements Shape {}

JEPs

JEP状态分类标题中文描述
JEP 339正式安全/加密Edwards-Curve Digital Signature Algorithm (EdDSA)支持 EdDSA 数字签名。
JEP 360预览语言Sealed Classes (Preview)密封类预览,限制可继承层次。
JEP 371正式库/APIHidden Classes隐藏类,支持框架生成不可发现类。
JEP 372移除/禁用工具/平台Remove the Nashorn JavaScript Engine移除 Nashorn JS 引擎。
JEP 373正式库/APIReimplement the Legacy DatagramSocket API重写旧 DatagramSocket API。
JEP 374废弃GC/RuntimeDisable and Deprecate Biased Locking默认禁用并废弃偏向锁。
JEP 375第二次预览语言Pattern Matching for instanceof (Second Preview)instanceof 模式匹配第二次预览。
JEP 377正式GC/RuntimeZGC: A Scalable Low-Latency Garbage CollectorZGC 转正。
JEP 378正式语言Text Blocks文本块转正。
JEP 379正式GC/RuntimeShenandoah: A Low-Pause-Time Garbage CollectorShenandoah 转正。
JEP 381移除/禁用工具/平台Remove the Solaris and SPARC Ports移除 Solaris 和 SPARC port。
JEP 383第二次孵化Panama/向量/原生Foreign-Memory Access API (Second Incubator)外部内存访问 API 第二次孵化。
JEP 384第二次预览语言Records (Second Preview)Records 第二次预览。
JEP 385废弃库/APIDeprecate RMI Activation for Removal废弃 RMI Activation。

References