Skip to main content

Java 25

核心总结

  • LTS。Scoped Values、模块导入、紧凑源文件、灵活构造函数体、KDF、紧凑对象头和分代 Shenandoah 转正。

升级关注

  • LTS。Scoped Values、紧凑源文件、模块导入、KDF、紧凑对象头等转正,但 Structured Concurrency 仍是预览。

示例

Compact Source Files and Instance Main Methods

void main() {
IO.println("Hello, Java 25");
}

Module Import Declarations

import module java.base;

void main() {
System.out.println(List.of("a", "b"));
}

Scoped Values 正式

static final ScopedValue<String> REQUEST_ID = ScopedValue.newInstance();

ScopedValue.where(REQUEST_ID, "req-1").run(() -> {
System.out.println(REQUEST_ID.get());
});

JEPs

JEP状态分类标题中文描述
JEP 470预览安全/加密PEM Encodings of Cryptographic Objects (Preview)PEM 编码加密对象 API 预览。
JEP 502预览库/APIStable Values (Preview)Stable Values 预览,提供一次初始化后稳定读取的值容器。
JEP 503移除/禁用库/APIRemove the 32-bit x86 Port移除 32-bit x86 port。
JEP 505第五次预览并发/LoomStructured Concurrency (Fifth Preview)结构化并发第五次预览。
JEP 506正式并发/LoomScoped ValuesScoped Values 转正。
JEP 507第三次预览语言Primitive Types in Patterns, instanceof, and switch (Third Preview)原始类型模式第三次预览。
JEP 508第十次孵化Panama/向量/原生Vector API (Tenth Incubator)Vector API 第十次孵化。
JEP 509实验工具/平台JFR CPU-Time Profiling (Experimental)JFR CPU 时间 profiling 实验。
JEP 510正式Panama/向量/原生Key Derivation Function APIKDF API 转正。
JEP 511正式语言Module Import Declarations模块导入声明转正。
JEP 512正式语言Compact Source Files and Instance Main Methods紧凑源文件和实例 main 转正。
JEP 513正式语言Flexible Constructor Bodies灵活构造函数体转正。
JEP 514正式库/APIAhead-of-Time Command-Line ErgonomicsAOT 命令行体验改进。
JEP 515正式库/APIAhead-of-Time Method ProfilingAOT 方法 profiling。
JEP 518正式工具/平台JFR Cooperative SamplingJFR 协作式采样。
JEP 519正式GC/RuntimeCompact Object Headers紧凑对象头转正。
JEP 520正式工具/平台JFR Method Timing & TracingJFR 方法计时和追踪。
JEP 521正式GC/RuntimeGenerational Shenandoah分代 Shenandoah 转正。

References