Java 9 - 21:新特性解读(持续连载)
Java 9 - 21:新特性解读(持续连载)
2022年3月下旬的时候,Java已经更新到了18。但我们似乎很多开发者的Java认识还都停留在Java 8,所以DD计划做一个新的专栏内容,专注分享Java前沿知识,内容将涵盖从Java 9 - 最新版本的各种有意思的新特性解读,持续连载!收藏起来!
以下内容中,不是每一个点都会特别开一篇来介绍,能简单说明且与我们日常开发关系不大的,就不单独开篇了。
对于Preview功能,如果您不知道如何运行,可以查看Java新特性中的Preview功能如何运行和调试
Java 21
2023年9月20日,Oracle公司宣布Java 21正式发布。该版本是继JDK 17之后最新的长期支持版本(LTS),将获得至少8年的支持!
Java 21 号称具有数千项性能、稳定性和安全性改进。新的 JDK 21 包括对 15 项改进的抢先体验,这些增强功能是在 Oracle CloudWorld 2023 会议上宣布的,包括支持虚拟线程以提高整体吞吐量,以及增加对向量应用编程接口(API)的支持,从而更轻松地构建涉及人工智能 AI 模型的 Java 应用。
该版本主要有以下特性,我们将在Java新特性专栏中,持续连载解读各项更新,欢迎关注收藏!
- 431: Sequenced Collections
- 439: Generational ZGC
- 440: Record Patterns
- 441: Pattern Matching for switch
- 444: Virtual Threads
- 449: Deprecate the Windows 32-bit x86 Port for Removal:Windows 32位x86端口已标记为在未来版本中弃用和删除
- 451: Prepare to Disallow the Dynamic Loading of Agents
- 452: Key Encapsulation Mechanism API:在加密领域,KEM API 是一个重要的补充。它使应用程序能够使用先进的 KEM 算法通过公共加密技术保护对称密钥,支持下一代加密。
以下是预览和孵化特性
- 430: String Templates (Preview)
- 442: Foreign Function & Memory API (Third Preview)
- 443: Unnamed Patterns and Variables (Preview)
- 445: Unnamed Classes and Instance Main Methods (Preview)
- 446: Scoped Values (Preview):还在测试中的一项新功能,可让您共享线程内和线程间无法更改的数据。这比使用线程局部变量更好,特别是当您使用大量虚拟线程时。线程局部变量存在一些问题,例如它们可能会更改太多、持续时间太长以及使用成本昂贵。作用域值(Scoped Values)允许您在大型程序的各个部分之间安全地共享数据,而无需使用方法参数。这个想法在JDK 20中得到了测试。
- 448: Vector API (Sixth Incubator)
- 453: Structured Concurrency (Preview)
Java 20
该版本推出的均为孵化与预览功能,所以这里不做单独的详细解读,大部分内容均放在Java 21中介绍。
以下内容在Java 21中正式定稿:
- 432: Record Patterns (Second Preview):终稿见440: Record Patterns
- 433: Pattern Matching for switch (Fourth Preview):终稿见441: Pattern Matching for switch
- 436: Virtual Threads (Second Preview):终稿见444: Virtual Threads
以下内容在Java 21中继续迭代:
- 429: Scoped Values (Incubator)
- 434: Foreign Function & Memory API (Second Preview)
- 437: Structured Concurrency (Second Incubator)
- 438: Vector API (Fifth Incubator)
Java 19
该版本推出的均为孵化与预览功能,所以这里不做单独的详细解读,大部分内容均放在Java 21中介绍。
- 422: Linux/RISC-V Port
以下预览特性在Java 21中正式定稿:
- 405: Record Patterns (Preview):终稿见440: Record Patterns
- 425: Virtual Threads (Preview):终稿见444: Virtual Threads
- 427: Pattern Matching for switch (Third Preview):终稿见441: Pattern Matching for switch
以下内容在Java 21中继续迭代:
- 424: Foreign Function & Memory API (Preview)
- 426: Vector API (Fourth Incubator)
- 428: Structured Concurrency (Incubator)
Java 18
- 400: UTF-8 by Default
- 408: Simple Web Server
- 413: Code Snippets in Java API Documentation
- 416: Reimplement Core Reflection with Method Handles
- 417: Vector API (Third Incubator)
- 418: Internet-Address Resolution SPI
- 419: Foreign Function & Memory API (Second Incubator)
- 420: Pattern Matching for switch (Second Preview):见Java 21终稿
- 421: Deprecate Finalization for Removal:废弃finalize方法,方便后续移除
Java 17
- 306: Restore Always-Strict Floating-Point Semantics
- 356: Enhanced Pseudo-Random Number Generators
- 382: New macOS Rendering Pipeline
- 391: macOS/AArch64 Port
- 398: Deprecate the Applet API for Removal
- 403: Strongly Encapsulate JDK Internals
- 406: Pattern Matching for switch (Preview)
- 407: Remove RMI Activation
- 409: Sealed Classes
- 410: Remove the Experimental AOT and JIT Compiler
- 411: Deprecate the Security Manager for Removal
- 412: Foreign Function & Memory API (Incubator)
- 414: Vector API (Second Incubator)
- 415: Context-Specific Deserialization Filters
Java 16
- 338: Vector API (Incubator)
- 347: Enable C++14 Language Features
- 357: Migrate from Mercurial to Git
- 369: Migrate to GitHub
- 376: ZGC: Concurrent Thread-Stack Processing
- 380: Unix-Domain Socket Channels
- 386: Alpine Linux Port
- 387: Elastic Metaspace
- 388: Windows/AArch64 Port
- 389: Foreign Linker API (Incubator)
- 390: Warnings for Value-Based Classes
- 392: Packaging Tool
- 393: Foreign-Memory Access API (Third Incubator)
- 394: Pattern Matching for instanceof
- 395: Records
- 396: Strongly Encapsulate JDK Internals by Default
- 397: Sealed Classes (Second Preview)
Java 15
- 339: Edwards-Curve Digital Signature Algorithm (EdDSA)
- 360: Sealed Classes (Preview)
- 371: Hidden Classes
- 372: Remove the Nashorn JavaScript Engine
- 373: Reimplement the Legacy DatagramSocket API
- 374: Disable and Deprecate Biased Locking
- 375: Pattern Matching for instanceof (Second Preview)
- 377: ZGC: A Scalable Low-Latency Garbage Collector
- 378: Text Blocks
- 379: Shenandoah: A Low-Pause-Time Garbage Collector
- 381: Remove the Solaris and SPARC Ports
- 383: Foreign-Memory Access API (Second Incubator)
- 384: Records (Second Preview)
- 385: Deprecate RMI Activation for Removal
Java 14
- 305: Pattern Matching for instanceof (Preview)
- 343: Packaging Tool (Incubator)
- 345: NUMA-Aware Memory Allocation for G1
- 349: JFR Event Streaming
- 352: Non-Volatile Mapped Byte Buffers
- 358: Helpful NullPointerExceptions
- 359: Records (Preview)
- 361: Switch Expressions (Standard)
- 362: Deprecate the Solaris and SPARC Ports
- 363: Remove the Concurrent Mark Sweep (CMS) Garbage Collector
- 364: ZGC on macOS
- 365: ZGC on Windows
- 366: Deprecate the ParallelScavenge + SerialOld GC Combination
- 367: Remove the Pack200 Tools and API
- 368: Text Blocks (Second Preview)
- 370: Foreign-Memory Access API (Incubator)
Java 13
- 350: Dynamic CDS Archives
- 351: ZGC: Uncommit Unused Memory
- 353: Reimplement the Legacy Socket API
- 354: Switch Expressions (Preview)
- 355: Text Blocks (Preview)
Java 12
- 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
- 230: Microbenchmark Suite
- 325: Switch Expressions (Preview)
- 334: JVM Constants API
- 340: One AArch64 Port, Not Two
- 341: Default CDS Archives
- 344: Abortable Mixed Collections for G1
- 346: Promptly Return Unused Committed Memory from G1
Java 11
- 181: Nest-Based Access Control
- 309: Dynamic Class-File Constants
- 315: Improve Aarch64 Intrinsics
- 318: Epsilon: A No-Op Garbage Collector
- 320: Remove the Java EE and CORBA Modules
- 321: HTTP Client (Standard)
- 323: Local-Variable Syntax for Lambda Parameters
- 324: Key Agreement with Curve25519 and Curve448
- 327: Unicode 10
- 328: Flight Recorder
- 329: ChaCha20 and Poly1305 Cryptographic Algorithms
- 330: Launch Single-File Source-Code Programs
- 331: Low-Overhead Heap Profiling
- 332: Transport Layer Security (TLS) 1.3
- 333: ZGC: A Scalable Low-Latency Garbage Collector(Experimental)
- 335: Deprecate the Nashorn JavaScript Engine
- 336: Deprecate the Pack200 Tools and API
Java 10
- 286: Local-Variable Type Inference
- 296: Consolidate the JDK Forest into a Single Repository
- 304: Garbage-Collector Interface
- 307: Parallel Full GC for G1
- 310: Application Class-Data Sharing
- 312: Thread-Local Handshakes
- 313: Remove the Native-Header Generation Tool (javah)
- 314: Additional Unicode Language-Tag Extensions
- 316: Heap Allocation on Alternative Memory Devices
- 317: Experimental Java-Based JIT Compiler
- 319: Root Certificates
- 322: Time-Based Release Versioning
Java 9
- 102: Process API Updates
- 110: HTTP 2 Client
- 143: Improve Contended Locking
- 158: Unified JVM Logging
- 165: Compiler Control
- 193: Variable Handles
- 197: Segmented Code Cache
- 199: Smart Java Compilation, Phase Two
- 200: The Modular JDK
- 201: Modular Source Code
- 211: Elide Deprecation Warnings on Import Statements
- 212: Resolve Lint and Doclint Warnings
- 213: Milling Project Coin
- 214: Remove GC Combinations Deprecated in JDK 8
- 215: Tiered Attribution for javac
- 216: Process Import Statements Correctly
- 217: Annotations Pipeline 2.0
- 219: Datagram Transport Layer Security (DTLS)
- 220: Modular Run-Time Images
- 221: Simplified Doclet API
- 222: jshell: The Java Shell (Read-Eval-Print Loop)
- 223: New Version-String Scheme
- 224: HTML5 Javadoc
- 225: Javadoc Search
- 226: UTF-8 Property Files
- 227: Unicode 7.0
- 228: Add More Diagnostic Commands
- 229: Create PKCS12 Keystores by Default
- 231: Remove Launch-Time JRE Version Selection
- 232: Improve Secure Application Performance
- 233: Generate Run-Time Compiler Tests Automatically
- 235: Test Class-File Attributes Generated by javac
- 236: Parser API for Nashorn
- 237: Linux/AArch64 Port
- 238: Multi-Release JAR Files
- 240: Remove the JVM TI hprof Agent
- 241: Remove the jhat Tool
- 243: Java-Level JVM Compiler Interface
- 244: TLS Application-Layer Protocol Negotiation Extension
- 245: Validate JVM Command-Line Flag Arguments
- 246: Leverage CPU Instructions for GHASH and RSA
- 247: Compile for Older Platform Versions
- 248: Make G1 the Default Garbage Collector
- 249: OCSP Stapling for TLS
- 250: Store Interned Strings in CDS Archives
- 251: Multi-Resolution Images
- 252: Use CLDR Locale Data by Default
- 253: Prepare JavaFX UI Controls & CSS APIs for Modularization
- 254: Compact Strings
- 255: Merge Selected Xerces 2.11.0 Updates into JAXP
- 256: BeanInfo Annotations
- 257: Update JavaFX/Media to Newer Version of GStreamer
- 258: HarfBuzz Font-Layout Engine
- 259: Stack-Walking API
- 260: Encapsulate Most Internal APIs
- 261: Module System
- 262: TIFF Image I/O
- 263: HiDPI Graphics on Windows and Linux
- 264: Platform Logging API and Service
- 265: Marlin Graphics Renderer
- 266: More Concurrency Updates
- 267: Unicode 8.0
- 268: XML Catalogs
- 269: Convenience Factory Methods for Collections
- 270: Reserved Stack Areas for Critical Sections
- 271: Unified GC Logging
- 272: Platform-Specific Desktop Features
- 273: DRBG-Based SecureRandom Implementations
- 274: Enhanced Method Handles
- 275: Modular Java Application Packaging
- 276: Dynamic Linking of Language-Defined Object Models
- 277: Enhanced Deprecation
- 278: Additional Tests for Humongous Objects in G1
- 279: Improve Test-Failure Troubleshooting
- 280: Indify String Concatenation
- 281: HotSpot C++ Unit-Test Framework
- 282: jlink: The Java Linker
- 283: Enable GTK 3 on Linux
- 284: New HotSpot Build System
- 285: Spin-Wait Hints
- 287: SHA-3 Hash Algorithms
- 288: Disable SHA-1 Certificates
- 289: Deprecate the Applet API
- 290: Filter Incoming Serialization Data
- 291: Deprecate the Concurrent Mark Sweep (CMS) Garbage Collector
- 292: Implement Selected ECMAScript 6 Features in Nashorn
- 294: Linux/s390x Port
- 295: Ahead-of-Time Compilation
- 297: Unified arm32/arm64 Port
- 298: Remove Demos and Samples
- 299: Reorganize Documentation
对文章形式感兴趣的可以关注我的网站程序猿DD、或公众号程序猿DD。对视频形式感兴趣的可以关注我的B站程序猿DD、或视频号程序猿DD。