Java 新特性¶
Java 25¶
JDK 25 于 2025 年 9 月 16 日 发布,是 LTS(长期支持版),至此为止,目前有 JDK8、JDK11、JDK17、JDK21 和 JDK 25 这五个长期支持版了。
共有 18 个新特性:
- JEP 470: PEM Encodings of Cryptographic Objects (Preview)
- JEP 502: Stable Values (Preview)
- JEP 503: Remove the 32-bit x86 Port
- JEP 505: Structured Concurrency (Fifth Preview) (结构化并发, 第五次预览)
- JEP 506: Scoped Values (作用域值)
- JEP 507: Primitive Types in Patterns, instanceof, and switch (Third Preview) (模式匹配支持基本类型, 第三次预览)
- JEP 508: Vector API (Tenth Incubator) (向量 API, 第十次孵化)
- JEP 509: JFR CPU-Time Profiling (Experimental)
- JEP 510: Key Derivation Function API
- JEP 511: Module Import Declarations (模块导入声明)
- JEP 512: Compact Source Files and Instance Main Methods (紧凑源文件与实例主方法)
- JEP 513: Flexible Constructor Bodies (灵活的构造函数体)
- JEP 514: Ahead-of-Time Command-Line Ergonomics
- JEP 515: Ahead-of-Time Method Profiling
- JEP 518: JFR Cooperative Sampling
- JEP 519: Compact Object Headers (紧凑对象头)
- JEP 520: JFR Method Timing & Tracing
- JEP 521: Generational Shenandoah (分代 Shenandoah GC)
Java 24¶
Features
- JEP 404: Generational Shenandoah (Experimental)
- JEP 450: Compact Object Headers (Experimental)
- JEP 472: Prepare to Restrict the Use of JNI
- JEP 475: Late Barrier Expansion for G1
- JEP 478: Key Derivation Function API (Preview)
- JEP 479: Remove the Windows 32-bit x86 Port
- JEP 483: Ahead-of-Time Class Loading & Linking
- JEP 484: Class-File API
- JEP 485: Stream Gatherers
- JEP 486: Permanently Disable the Security Manager
- JEP 487: Scoped Values (Fourth Preview)
- JEP 488: Primitive Types in Patterns, instanceof, and switch (Second Preview)
- JEP 489: Vector API (Ninth Incubator)
- JEP 490: ZGC: Remove the Non-Generational Mode
- JEP 491: Synchronize Virtual Threads without Pinning
- JEP 492: Flexible Constructor Bodies (Third Preview)
- JEP 493: Linking Run-Time Images without JMODs
- JEP 494: Module Import Declarations (Second Preview)
- JEP 495: Simple Source Files and Instance Main Methods (Fourth Preview)
- JEP 496: Quantum-Resistant Module-Lattice-Based Key Encapsulation Mechanism
- JEP 497: Quantum-Resistant Module-Lattice-Based Digital Signature Algorithm
- JEP 498: Warn upon Use of Memory-Access Methods in sun.misc.Unsafe
- JEP 499: Structured Concurrency (Fourth Preview)
- JEP 501: Deprecate the 32-bit x86 Port for Removal
Java 23¶
Features
- JEP 455: Primitive Types in Patterns, instanceof, and switch (Preview)
- JEP 466: Class-File API (Second Preview)
- JEP 467: Markdown Documentation Comments
- JEP 469: Vector API (Eighth Incubator)
- JEP 473: Stream Gatherers (Second Preview)
- JEP 471: Deprecate the Memory-Access Methods in sun.misc.Unsafe for Removal
- JEP 474: ZGC: Generational Mode by Default
- JEP 476: Module Import Declarations (Preview)
- JEP 477: Implicitly Declared Classes and Instance Main Methods (Third Preview)
- JEP 480: Structured Concurrency (Third Preview)
- JEP 481: Scoped Values (Third Preview)
- JEP 482: Flexible Constructor Bodies (Second Preview)
Java 22¶
Features
- JEP 423: Region Pinning for G1
- JEP 447: Statements before super(...) (Preview)
- JEP 454: Foreign Function & Memory API
- JEP 456: Unnamed Variables & Patterns
- JEP 457: Class-File API (Preview)
- JEP 458: Launch Multi-File Source-Code Programs
- JEP 459: String Templates (Second Preview)
- JEP 460: Vector API (Seventh Incubator)
- JEP 461: Stream Gatherers (Preview)
- JEP 462: Structured Concurrency (Second Preview)
- JEP 463: Implicitly Declared Classes and Instance Main Methods (Second Preview)
- JEP 464: Scoped Values (Second Preview)
Java 21¶
2023年9月20日,Oracle公司宣布Java 21正式发布。该版本是继JDK 17之后最新的长期支持版本(LTS),将获得至少8年的支持!
Java 21 号称具有数千项性能、稳定性和安全性改进,包括支持虚拟线程以提高整体吞吐量,以及增加对向量应用编程接口(API)的支持,从而更轻松地构建涉及人工智能 AI 模型的 Java 应用。
- JEP 431: Sequenced Collections
- JEP 439: Generational ZGC (分代ZGC)
- JEP 440: Record Patterns (记录模式)
- JEP 441: Pattern Matching for switch
- JEP 444: Virtual Threads
- JEP 449: Deprecate the Windows 32-bit x86 Port for Removal
- JEP 451: Prepare to Disallow the Dynamic Loading of Agents
- JEP 452: Key Encapsulation Mechanism API:KEM 算法通过公共加密技术保护对称密钥。
以下是预览和孵化特性
- JEP 430: String Templates (Preview) (字符串模版)
- JEP 442: Foreign Function & Memory API (Third Preview)
- JEP 443: Unnamed Patterns and Variables (Preview)
- JEP 445: Unnamed Classes and Instance Main Methods (Preview)
- JEP 446: Scoped Values (Preview)
- JEP 448: Vector API (Sixth Incubator)
- JEP 453: Structured Concurrency (Preview)
Java 20¶
以下内容在Java 21中正式定稿:
- JEP 432: Record Patterns (Second Preview):终稿见440: Record Patterns
- JEP 433: Pattern Matching for switch (Fourth Preview):终稿见441: Pattern Matching for switch
- JEP 436: Virtual Threads (Second Preview):终稿见444: Virtual Threads
以下内容在Java 21中继续迭代:
- JEP 429: Scoped Values (Incubator)
- JEP 434: Foreign Function & Memory API (Second Preview)
- JEP 437: Structured Concurrency (Second Incubator)
- JEP 438: Vector API (Fifth Incubator)
Java 19¶
- JEP 422: Linux/RISC-V Port
以下预览特性在Java 21中正式定稿:
- JEP 405: Record Patterns (Preview):终稿见440: Record Patterns
- JEP 425: Virtual Threads (Preview):终稿见444: Virtual Threads
- JEP 427: Pattern Matching for switch (Third Preview):终稿见441: Pattern Matching for switch
以下内容在Java 21中继续迭代:
- JEP 424: Foreign Function & Memory API (Preview)
- JEP 426: Vector API (Fourth Incubator)
- JEP 428: Structured Concurrency (Incubator)
Java 18¶
- JEP 400: UTF-8 by Default
- JEP 408: Simple Web Server
- JEP 413: Code Snippets in Java API Documentation
- JEP 416: Reimplement Core Reflection with Method Handles
- JEP 417: Vector API (Third Incubator)
- JEP 418: Internet-Address Resolution SPI
- JEP 419: Foreign Function & Memory API (Second Incubator)
- JEP 420: Pattern Matching for switch (Second Preview):见Java 21终稿
- JEP 421: Deprecate Finalization for Removal:废弃finalize方法,方便后续移除
Java 17¶
- JEP 306: Restore Always-Strict Floating-Point Semantics
- JEP 356: Enhanced Pseudo-Random Number Generators
- JEP 382: New macOS Rendering Pipeline
- JEP 391: macOS/AArch64 Port
- JEP 398: Deprecate the Applet API for Removal
- JEP 403: Strongly Encapsulate JDK Internals
- JEP 406: Pattern Matching for switch (Preview)
- JEP 407: Remove RMI Activation
- JEP 409: Sealed Classes
- JEP 410: Remove the Experimental AOT and JIT Compiler
- JEP 411: Deprecate the Security Manager for Removal
- JEP 412: Foreign Function & Memory API (Incubator)
- JEP 414: Vector API (Second Incubator)
- JEP 415: Context-Specific Deserialization Filters
Java 16¶
- JEP 338: Vector API (Incubator)
- JEP 347: Enable C++14 Language Features
- JEP 357: Migrate from Mercurial to Git
- JEP 369: Migrate to GitHub
- JEP 376: ZGC: Concurrent Thread-Stack Processing
- JEP 380: Unix-Domain Socket Channels
- JEP 386: Alpine Linux Port
- JEP 387: Elastic Metaspace
- JEP 388: Windows/AArch64 Port
- JEP 389: Foreign Linker API (Incubator)
- JEP 390: Warnings for Value-Based Classes
- JEP 392: Packaging Tool
- JEP 393: Foreign-Memory Access API (Third Incubator)
- JEP 394: Pattern Matching for instanceof
- JEP 395: Records
- JEP 396: Strongly Encapsulate JDK Internals by Default
- JEP 397: Sealed Classes (Second Preview)
Java 15¶
- JEP 339: Edwards-Curve Digital Signature Algorithm (EdDSA)
- JEP 360: Sealed Classes (Preview)
- JEP 371: Hidden Classes
- JEP 372: Remove the Nashorn JavaScript Engine
- JEP 373: Reimplement the Legacy DatagramSocket API
- JEP 374: Disable and Deprecate Biased Locking
- JEP 375: Pattern Matching for instanceof (Second Preview)
- JEP 377: ZGC: A Scalable Low-Latency Garbage Collector
- JEP 378: Text Blocks
- JEP 379: Shenandoah: A Low-Pause-Time Garbage Collector
- JEP 381: Remove the Solaris and SPARC Ports
- JEP 383: Foreign-Memory Access API (Second Incubator)
- JEP 384: Records (Second Preview)
- JEP 385: Deprecate RMI Activation for Removal
Java 14¶
- JEP 305: Pattern Matching for instanceof (Preview)
- 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
- JEP 359: Records (Preview)
- JEP 361: Switch Expressions (Standard)
- JEP 362: Deprecate the Solaris and SPARC Ports
- 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)
Java 13¶
- JEP 350: Dynamic CDS Archives
- JEP 351: ZGC: Uncommit Unused Memory
- JEP 353: Reimplement the Legacy Socket API
- JEP 354: Switch Expressions (Preview)
- JEP 355: Text Blocks (Preview)
Java 12¶
- JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
- JEP 230: Microbenchmark Suite
- JEP 325: Switch Expressions (Preview)
- JEP 334: JVM Constants API
- JEP 340: One AArch64 Port, Not Two
- JEP 341: Default CDS Archives
- JEP 344: Abortable Mixed Collections for G1
- JEP 346: Promptly Return Unused Committed Memory from G1
Java 11¶
- JEP 181: Nest-Based Access Control
- JEP 309: Dynamic Class-File Constants
- JEP 315: Improve Aarch64 Intrinsics
- JEP 318: Epsilon: A No-Op Garbage Collector
- JEP 320: Remove the Java EE and CORBA Modules
- JEP 321: HTTP Client (Standard)
- JEP 323: Local-Variable Syntax for Lambda Parameters
- JEP 324: Key Agreement with Curve25519 and Curve448
- JEP 327: Unicode 10
- JEP 328: Flight Recorder
- JEP 329: ChaCha20 and Poly1305 Cryptographic Algorithms
- JEP 330: Launch Single-File Source-Code Programs
- JEP 331: Low-Overhead Heap Profiling
- JEP 332: Transport Layer Security (TLS) 1.3
- JEP 333: ZGC: A Scalable Low-Latency Garbage Collector(Experimental)
- JEP 335: Deprecate the Nashorn JavaScript Engine
- JEP 336: Deprecate the Pack200 Tools and API
Java 10¶
- JEP 286: Local-Variable Type Inference
- JEP 296: Consolidate the JDK Forest into a Single Repository
- JEP 304: Garbage-Collector Interface
- JEP 307: Parallel Full GC for G1
- JEP 310: Application Class-Data Sharing
- JEP 312: Thread-Local Handshakes
- JEP 313: Remove the Native-Header Generation Tool (javah)
- JEP 314: Additional Unicode Language-Tag Extensions
- JEP 316: Heap Allocation on Alternative Memory Devices
- JEP 317: Experimental Java-Based JIT Compiler
- JEP 319: Root Certificates
- JEP 322: Time-Based Release Versioning
Java 9¶
- JEP 102: Process API Updates
- JEP 110: HTTP 2 Client
- JEP 143: Improve Contended Locking
- JEP 158: Unified JVM Logging
- JEP 165: Compiler Control
- JEP 193: Variable Handles
- JEP 197: Segmented Code Cache
- JEP 199: Smart Java Compilation, Phase Two
- JEP 200: The Modular JDK
- JEP 201: Modular Source Code
- JEP 211: Elide Deprecation Warnings on Import Statements
- JEP 212: Resolve Lint and Doclint Warnings
- JEP 213: Milling Project Coin
- JEP 214: Remove GC Combinations Deprecated in JDK 8
- JEP 215: Tiered Attribution for javac
- JEP 216: Process Import Statements Correctly
- JEP 217: Annotations Pipeline 2.0
- JEP 219: Datagram Transport Layer Security (DTLS)
- JEP 220: Modular Run-Time Images
- JEP 221: Simplified Doclet API
- JEP 222: jshell: The Java Shell (Read-Eval-Print Loop)
- JEP 223: New Version-String Scheme
- JEP 224: HTML5 Javadoc
- JEP 225: Javadoc Search
- JEP 226: UTF-8 Property Files
- JEP 227: Unicode 7.0
- JEP 228: Add More Diagnostic Commands
- JEP 229: Create PKCS12 Keystores by Default
- JEP 231: Remove Launch-Time JRE Version Selection
- JEP 232: Improve Secure Application Performance
- JEP 233: Generate Run-Time Compiler Tests Automatically
- JEP 235: Test Class-File Attributes Generated by javac
- JEP 236: Parser API for Nashorn
- JEP 237: Linux/AArch64 Port
- JEP 238: Multi-Release JAR Files
- JEP 240: Remove the JVM TI hprof Agent
- JEP 241: Remove the jhat Tool
- JEP 243: Java-Level JVM Compiler Interface
- JEP 244: TLS Application-Layer Protocol Negotiation Extension
- JEP 245: Validate JVM Command-Line Flag Arguments
- JEP 246: Leverage CPU Instructions for GHASH and RSA
- JEP 247: Compile for Older Platform Versions
- JEP 248: Make G1 the Default Garbage Collector
- JEP 249: OCSP Stapling for TLS
- JEP 250: Store Interned Strings in CDS Archives
- JEP 251: Multi-Resolution Images
- JEP 252: Use CLDR Locale Data by Default
- JEP 253: Prepare JavaFX UI Controls & CSS APIs for Modularization
- JEP 254: Compact Strings
- JEP 255: Merge Selected Xerces 2.11.0 Updates into JAXP
- JEP 256: BeanInfo Annotations
- JEP 257: Update JavaFX/Media to Newer Version of GStreamer
- JEP 258: HarfBuzz Font-Layout Engine
- JEP 259: Stack-Walking API
- JEP 260: Encapsulate Most Internal APIs
- JEP 261: Module System
- JEP 262: TIFF Image I/O
- JEP 263: HiDPI Graphics on Windows and Linux
- JEP 264: Platform Logging API and Service
- JEP 265: Marlin Graphics Renderer
- JEP 266: More Concurrency Updates
- JEP 267: Unicode 8.0
- JEP 268: XML Catalogs
- JEP 269: Convenience Factory Methods for Collections
- JEP 270: Reserved Stack Areas for Critical Sections
- JEP 271: Unified GC Logging
- JEP 272: Platform-Specific Desktop Features
- JEP 273: DRBG-Based SecureRandom Implementations
- JEP 274: Enhanced Method Handles
- JEP 275: Modular Java Application Packaging
- JEP 276: Dynamic Linking of Language-Defined Object Models
- JEP 277: Enhanced Deprecation
- JEP 278: Additional Tests for Humongous Objects in G1
- JEP 279: Improve Test-Failure Troubleshooting
- JEP 280: Indify String Concatenation
- JEP 281: HotSpot C++ Unit-Test Framework
- JEP 282: jlink: The Java Linker
- JEP 283: Enable GTK 3 on Linux
- JEP 284: New HotSpot Build System
- JEP 285: Spin-Wait Hints
- JEP 287: SHA-3 Hash Algorithms
- JEP 288: Disable SHA-1 Certificates
- JEP 289: Deprecate the Applet API
- JEP 290: Filter Incoming Serialization Data
- JEP 291: Deprecate the Concurrent Mark Sweep (CMS) Garbage Collector
- JEP 292: Implement Selected ECMAScript 6 Features in Nashorn
- JEP 294: Linux/s390x Port
- JEP 295: Ahead-of-Time Compilation
- JEP 297: Unified arm32/arm64 Port
- JEP 298: Remove Demos and Samples
- JEP 299: Reorganize Documentation
Java8¶
- JEP Lambda 表达式
- JEP 方法引用
- JEP 接口默认方法
- JEP Stream API
- JEP 函数式接口
- JEP Optional 类
- JEP Date/Time API
- JEP 注解增强