Skip to main content

Java 24

核心总结

  • Class-File API 和 Stream Gatherers 转正,Security Manager 永久禁用,虚拟线程同步 pinning 问题修复,AOT 启动链路开始落地。

升级关注

  • Security Manager 永久禁用;依赖 Security Manager 沙箱模型的系统必须调整。
  • 虚拟线程 synchronized pinning 问题改善,适合重新评估虚拟线程阻塞场景。

示例

Stream Gatherers 正式

// Gatherers 提供标准和自定义中间操作扩展点。
var windows = java.util.stream.Stream.of(1, 2, 3, 4)
.gather(java.util.stream.Gatherers.windowFixed(2))
.toList();

Simple Source Files Preview

// javac --enable-preview --release 24 Hello.java
void main() {
IO.println("hello");
}

JEPs

JEP状态分类标题中文描述
JEP 404实验GC/RuntimeGenerational Shenandoah (Experimental)分代 Shenandoah 实验。
JEP 450实验GC/RuntimeCompact Object Headers (Experimental)紧凑对象头实验,目标降低对象内存开销。
JEP 472迁移预告Panama/向量/原生Prepare to Restrict the Use of JNI准备限制 JNI 使用,推动显式授权和 FFM 迁移。
JEP 475正式GC/RuntimeLate Barrier Expansion for G1G1 屏障后期展开,改善编译和性能。
JEP 478预览Panama/向量/原生Key Derivation Function API (Preview)KDF API 预览。
JEP 479移除/禁用工具/平台Remove the Windows 32-bit x86 Port移除 Windows 32-bit x86 port。
JEP 483正式库/APIAhead-of-Time Class Loading & LinkingAOT 类加载和链接,改善启动。
JEP 484正式工具/平台Class-File APIClass-File API 转正。
JEP 485正式库/APIStream GatherersStream Gatherers 转正。
JEP 486移除/禁用安全/加密Permanently Disable the Security Manager永久禁用 Security Manager。
JEP 487第四次预览并发/LoomScoped Values (Fourth Preview)Scoped Values 第四次预览。
JEP 488第二次预览语言Primitive Types in Patterns, instanceof, and switch (Second Preview)原始类型模式第二次预览。
JEP 489第九次孵化Panama/向量/原生Vector API (Ninth Incubator)Vector API 第九次孵化。
JEP 490移除/禁用GC/RuntimeZGC: Remove the Non-Generational ModeZGC 移除非分代模式。
JEP 491正式并发/LoomSynchronize Virtual Threads without Pinning虚拟线程在 synchronized 中不再 pin carrier thread。
JEP 492第三次预览语言Flexible Constructor Bodies (Third Preview)灵活构造函数体第三次预览。
JEP 493正式工具/平台Linking Run-Time Images without JMODs不依赖 JMOD 链接运行时镜像。
JEP 494第二次预览语言Module Import Declarations (Second Preview)模块导入声明第二次预览。
JEP 495第四次预览库/APISimple Source Files and Instance Main Methods (Fourth Preview)简单源文件和实例 main 第四次预览。
JEP 496正式安全/加密Quantum-Resistant Module-Lattice-Based Key Encapsulation MechanismML-KEM 后量子密钥封装。
JEP 497正式安全/加密Quantum-Resistant Module-Lattice-Based Digital Signature AlgorithmML-DSA 后量子数字签名。
JEP 498迁移预告Panama/向量/原生Warn upon Use of Memory-Access Methods in sun.misc.Unsafe使用 Unsafe 内存访问方法时发出警告。
JEP 499第四次预览并发/LoomStructured Concurrency (Fourth Preview)结构化并发第四次预览。
JEP 501废弃库/APIDeprecate the 32-bit x86 Port for Removal废弃 32-bit x86 port。

References