2024年主流使用的JDK版本及其核心特性介绍

时间:2025-04-24 17:33:57
  • Nest-Based Access Control (JEP 181) 基于嵌套的访问控制:
    • Introduces the concept of nests, allowing classes within the same nest to access each other’s private members directly, simplifying compiler-generated access code and enhancing maintainability.
    • 引入了 nest(嵌套)的概念,允许同一个 nest 中的类直接访问彼此的私有成员,从而简化编译器生成的访问代码并增强可维护性。
  • Dynamic Class-File Constants (JEP 309) 动态类文件常量:
    • Introduces a new constant pool item CONSTANT_Dynamic, allowing delayed constant computation, supporting more flexible and efficient constant handling.
    • 引入新的常量池项 CONSTANT_Dynamic,延迟常量的计算,支持更加灵活和高效的常量处理。
  • Local-Variable Syntax for Lambda Parameters (JEP 323) Lambda 参数的局部变量语法:
    • Allows the use of the var keyword in lambda expressions to declare parameters, providing consistency and enhancing code readability.
    • 允许在 lambda 表达式中使用 var 关键字来声明参数,提供一致性和增强代码的可读性。
  • HTTP Client (Standard) (JEP 321) HTTP 客户端(标准):
    • Standardizes the new HTTP Client  API for sending HTTP requests and receiving responses, supporting HTTP/1.1 and HTTP/2, and providing synchronous and asynchronous operations.
    • 标准化新的 HTTP 客户端 API,用于发送 HTTP 请求和接收响应,支持 HTTP/1.1 和 HTTP/2,并提供同步和异步操作。
  • Removal of the Java EE and CORBA Modules (JEP 320) 移除 Java EE 和 CORBA 模块:
    • Removes the Java EE and CORBA modules, which have been deprecated and are used less in modern  Java development.
    • 移除了 Java EE 和 CORBA 模块,这些模块已经被弃用并且在现代 Java 开发中使用较少。
  • Epsilon: A No-Op Garbage Collector (JEP 318) Epsilon:无操作垃圾收集器:
    • Introduces a new garbage collector, Epsilon, which does not perform any memory reclamation, mainly used for performance testing and memory pressure testing.
    • 引入了一个新的垃圾收集器 Epsilon,该垃圾收集器不执行任何内存回收操作,主要用于性能测试和内存压力测试。
  • Flight Recorder (JEP 328) 飞行记录器:
    • Provides a low-overhead event collection framework, allowing the collection of diagnostic and monitoring data for analyzing and debugging Java application performance issues.
    • 提供了一个低开销的事件收集框架,允许收集诊断和监控数据,用于分析和调试 Java 应用程序的性能问题。
  • Launch Single-File Source-Code Programs (JEP 330) 启动单文件源代码程序:
    • Allows the java command to run a single Java source file directly, simplifying the process of writing and executing small programs.
    • 允许使用 java 命令直接运行单个 Java 源文件,简化了小型程序的编写和执行流程。
  • ZGC: A Scalable Low-Latency Garbage Collector (Experimental) (JEP 333) ZGC:可伸缩的低延迟垃圾收集器(实验性):
    • Introduces the Z Garbage Collector (ZGC), a scalable low-latency garbage collector designed to handle large memory applications with low latency.
    • 引入了 Z Garbage Collector (ZGC),一个可伸缩的低延迟垃圾收集器,旨在处理大内存的低延迟应用。
  • Deprecate the Pack200 Tools and  API (JEP 336) 弃用 Pack200 工具和 API:
    • Marks the Pack200 tools and API as deprecated, planning to remove them in future releases.
    • 将 Pack200 工具和 API 标记为弃用,计划在未来的版本中移除。 这些特性和改进使  JDK 11 在性能、可维护性和现代化开发支持方面得到了显著提升。