Software-update: Java 21

Oracle heeft Java 21 uitgebracht. Het gaat om een long term support-release die dit keer acht jaar ondersteuning krijgt. Java is een van de populairste en meest gebruikte programmeertalen ter wereld. Hieronder vind je alle wijzigingen in JDK 21.

Along with thousands of performance, stability and security updates, Java 21 delivers dozens of new features and enhancements, 15 of those enhancements are significant enough to warrant their own JDK Enhancement Proposals - JEPs, covering six preview features and one incubator feature.

JEP Preview Features are fully specified and fully implemented Language or VM Features of the Java SE Platform; and yet impermanent. They are made available in JDK Feature Releases to allow for developer feedback based on real-world uses, before them becoming permanent in a future release. This also affords tool vendors the opportunity to work towards supporting features before they are finalized into the Java SE Standard.

JEP Incubator modules allow putting non-final APIs and non-final tools in the hands of developers and users to gather feedback that will ultimately improve the quality of the Java platform.

The 15 JEPs delivered with Java 21 are grouped into six categories mapping to key long-term Java technology projects and hardware support.

Project Amber

JEP 430: String Templates (Preview)

  • JEP Goals:
    • Simplifies the writing of Java programs by making it easy to express strings that include values computed at run time.
    • Enhances the readability of expressions that mix text and expressions, whether the text fits on a single source line (as with string literals) or spans several source lines (as with text blocks).
    • Improves the security of Java programs that compose strings from user-provided values and pass them to other systems (e.g., building queries for databases) by supporting validation and transformation of both the template and the values of its embedded expressions.
    • Retains flexibility by allowing Java libraries to define the formatting syntax used in string templates.
    • Simplifies the use of APIs that accept strings written in non-Java languages (e.g., SQL, XML, and JSON).
    • Enables the creation of non-string values computed from literal text and embedded expressions without having to transit through an intermediate string representation.
  • Value:
    • Following the goals of Project Amber, String Templates aims to make the Java programming language more readable, writable, and maintainable.

JEP 440: Record Patterns

  • JEP Goals:
    • Enhances the Java programming language by extending pattern matching to destructure instances of record classes, enabling more sophisticated data queries.
    • Add nested patterns, enabling more composable data queries.
  • Related to:
    • [JDK 19] JEP 405: Record Patterns (Preview)
    • [JDK 20] JEP 432: Record Patterns (2nd Preview)
  • Value:
    • Makes the Java programming language more productive by extending pattern matching to express more sophisticated, composable data queries.

JEP 441: Pattern Matching for switch

  • JEP Goals:
    • Expands the expressiveness and applicability of switch expressions and statements by allowing patterns to appear in case labels.
  • Allows the historical null-hostility of switch to be relaxed when desired.
    • Increases the safety of switch statements by requiring that pattern switch statements cover all possible input values.
    • Ensures that all existing switch expressions and statements continue to compile with no changes and execute with identical semantics.
  • Related to:
    • [JDK 17] JEP 406: Pattern Matching for switch (Preview)
    • [JDK 18] JEP 420: Pattern Matching for switch (2nd Preview)
    • [JDK 19] JEP 427: Pattern Matching for switch (3rd Preview)
    • [JDK 20] JEP 433: Pattern Matching for switch (4th Preview)
  • Value:
    • Improves the productivity of the Java programming language by making it more semantic so that complex data-oriented queries can be expressed concisely and safely.

JEP 443: Unnamed Pattern and Variable (Preview)

  • JEP Goals:
    • Enhances the Java language with unnamed patterns, which match a record component without stating the component's name or type, and unnamed variables, which can be initialized but not used. Both are denoted by an underscore character, _.
  • Value:
    • Improves the readability of record patterns by eliding unnecessary nested patterns.
    • Improves the maintainability of all code by identifying variables that must be declared (e.g., in a catch clause) but will not be used.

JEP 445: Unnamed Classes and Instance Main Methods (Preview)

  • JEP Goals:
    • Offers a smooth on-ramp to Java so that educators can introduce programming concepts in a gradual manner.
    • Helps students to write basic programs in a concise manner and grow their code gracefully as their skills grow.
    • Reduces the ceremony of writing simple programs such as scripts and command-line utilities.
    • Does not introduce a separate beginner's dialect of Java.
    • Does not introduce a separate beginners' toolchain; student programs should be compiled and run with the same tools that compile and run any Java program.
  • Value:
    • Evolves the Java language by reducing the boilerplate and ceremony so that students can write their first programs without needing to understand language features designed for large programs.

Project Loom

JEP 444: Virtual Threads

  • JEP Goals:
    • Enables server applications written in the simple thread-per-request style to scale with near-optimal hardware utilization.
    • Enables existing code that uses the java.lang.Thread API to adopt virtual threads with minimal change.
    • Enables easy troubleshooting, debugging, and profiling of virtual threads with existing JDK tools.
  • Relates to:
    • [JDK 20] JEP 436: Virtual Threads (2nd Preview)
    • [JDK 19] JEP 425: Virtual Threads (Preview)
  • Value:
    • Accelerates application development productivity such as apps targeted for cloud environments by introducing Virtual threads, which are lightweight threads that dramatically reduce the effort of writing, maintaining, and observing high-throughput concurrent applications.

JEP 446: Scoped Values (Preview)

  • JEP Goals:
    • Enables the sharing of immutable data within and across threads.
  • Related to:
    • [JDK 20] JEP 429: Scoped Values (Incubator)
  • Value:
    • Ease of use — Provides a programming model to share data both within a thread and with child threads, so as to simplify reasoning about data flow.
    • Comprehensibility — Makes the lifetime of shared data visible from the syntactic structure of code.
    • Robustness — Ensures that data shared by a caller can be retrieved only by legitimate callees.
    • Performance — Treats shared data as immutable so as to allow sharing by a large number of threads, and to enable runtime optimizations.

JEP 453: Structured Concurrency (Preview)

  • JEP Goals:
    • Simplifies concurrent programming by introducing an API for structured concurrency.
    • Promotes a style of concurrent programming that can eliminate common risks arising from cancellation and shutdown, such as thread leaks and cancellation delays.
    • Improves the observability of concurrent code.
  • Related to:
    • [JDK 19] JEP 428: Structured Concurrency (Incubator)
    • [JDK 20] JEP 437: Structured Concurrency (2nd Incubator)
  • Value:
    • Simplifies concurrent programming by introducing an API for structured concurrency. which streamlines error handling and cancellation, improves reliability, and enhances observability.

Project Panama

JEP 442: Foreign Function & Memory API (3rd Preview)

  • JEP Goals:
    • Introduces an API by which Java programs can interoperate with code and data outside of the Java runtime. By efficiently invoking foreign functions (i.e., code outside the JVM), and by safely accessing foreign memory (i.e., memory not managed by the JVM), the API enables Java programs to call native libraries and process native data without the brittleness and danger of JNI. This is a preview API.
  • Related to:
    • [JDK 19] JEP 424: Foreign Function & Memory API (Preview)
    • [JDK 20] JEP 434: Foreign Function & Memory API (2nd Preview)
  • Value:
    • Ease of use — Replaces the Java Native Interface (JNI) with a superior, pure-Java development model.
    • Performance — Provides performance that is comparable to, if not better than, existing APIs such as JNI and sun.misc.Unsafe.
    • Generality — Provides ways to operate on different kinds of foreign memory (e.g., native memory, persistent memory, and managed heap memory) and, over time, to accommodate other platforms (e.g., 32-bit x86) and foreign functions written in languages other than C (e.g., C++, Fortran).
    • Safety — Allows programs to perform unsafe operations on foreign memory but warn users about such operations by default.

JEP 448: Vector API (6th Incubator)

  • JEP Goals:
    • Introduces an API to express vector computations that reliably compile at runtime to optimal vector instructions on supported CPU architectures, thus achieving performance superior to equivalent scalar computations.
    • Included are the following notable changes:
      • Adds the exclusive or (xor) operation to vector masks.
      • Improves the performance of vector shuffles, especially when used to rearrange the elements of a vector and when converting between vectors.
  • Related to:
    • [JDK 16] JEP 338: Vector API (Incubator)
    • [JDK 17] JEP 414: Vector API (2nd Incubator)
    • [JDK 18] JEP 417: Vector API (3rd Incubator)
    • [JDK 19] JEP 426: Vector API (4th Incubator)
    • [JDK 20] JEP 438: Vector API (5th Incubator)
  • Value:
    • Offers a clear and concise API that is capable of clearly and concisely expressing a wide range of vector computations consisting of sequences of vector operations composed within loops and possibly with control flow
    • The API should be CPU architecture agnostic, enabling implementations on multiple architectures supporting vector instructions.
    • Offers a reliable runtime compilation and performance on x64 and AArch64 architectures.
    • Aligns with Project Valhalla.

Core Libraries

JEP 431: Sequenced Collections

  • JEP Goals:
    • Introduces new interfaces to represent collections with a defined encounter order. Each such collection has a well-defined first element, second element, and so forth, up to the last element.
    • Provides uniform APIs for accessing its first and last elements, and for processing its elements in reverse order.
  • Value:
    • Improves developer productivity by offering a uniform set of operations that apply across a collection type that represents a sequence of elements with a defined encounter order.

Performance Updates

JEP 439: Generational ZGC

  • JEP Goals:
    • Improves application performance by extending the Z Garbage Collector (ZGC) to maintain separate generations for young and old objects.
  • Value:
    • Applications running with Generational ZGC should enjoy:
      • Lower risks of allocations stalls.
      • Lower required heap memory overhead.
      • Lower garbage collection CPU overhead.
    • These benefits should come without significant throughput reduction compared to non-generational ZGC. The essential properties of non-generational ZGC should be preserved:
    • Pause times should not exceed 1 millisecond.
    • Heap sizes from a few hundred megabytes up to many terabytes should be supported.
    • Minimal manual configuration should be needed.

JEP 452: Key Encapsulation Mechanism API

  • JEP Goals:
    • Introduce an API for key encapsulation mechanisms (KEMs), an encryption technique for securing symmetric keys using public key cryptography.
  • Value:
    • Enables applications to use KEM algorithms such as the RSA Key Encapsulation Mechanism (RSA-KEM), the Elliptic Curve Integrated Encryption Scheme (ECIES), and candidate KEM algorithms for the National Institute of Standards and Technology (NIST) Post-Quantum Cryptography standardization process.
    • Enables the use of KEMs in higher level protocols such as Transport Level Security (TLS) and in cryptographic schemes such as Hybrid Public Key Encryption (HPKE, RFC 9180).
    • Allows security providers to implement KEM algorithms in either Java code or native code.
    • Includes an implementation of the Diffie-Hellman KEM (DHKEM) defined in §4.1 of RFC 9180.

Maintenance and Deprecation

JEP 449: Deprecate the 32-bit x86 Port for Removal

  • JEP Goals:
    • Deprecates the Windows 32-bit x86 port, with the intent to remove it in a future release.
  • Value:
    • Updates the build system to issue an error message when an attempt is made to configure a build for Windows 32-bit x86 (x86-32). The error message will be suppressible via a new configuration option.
    • Marks the port, and related port-specific features, as deprecated for removal in the relevant documentation.

JEP 451: Prepare to Disallow the Dynamic Loading of Agents

  • JEP Goals:
    • Issues warnings when agents are loaded dynamically into a running JVM. These warnings aim to prepare users for a future release which disallows the dynamic loading of agents by default in order to improve integrity by default. Serviceability tools that load agents at startup will not cause warnings to be issued in any release.
  • Value:
    • Prepares for a future release of the JDK that will, by default, disallow the loading of agents into a running JVM.
    • Reassesses the balance between serviceability, which involves ad-hoc changes to running code, and integrity, which assumes that running code is not arbitrarily changed.
    • Ensures that the majority of tools — which do not need to load agents dynamically — are unaffected.
    • Aligns the ability to load agents dynamically with other so-called "superpower" capabilities, such as deep reflection.
Releasestatus Stable
Besturingssystemen Scripttaal
Website https://blogs.oracle.com/java/post/the-arrival-of-java-21
Licentietype Freeware

Door Tijs Hofmans

Nieuwscoördinator

21-09-2023 • 14:32

4

Reacties (4)

4
4
1
0
0
2
Wijzig sortering
Waarom staat dit in de categorie "Besturingssystemen: Scripttaal" in het tabel onderaan het artikel?

[Reactie gewijzigd door Cobalt op 25 juli 2024 09:15]

en geen update historie....
@TijsZonderH hoort in dit rijtje lijkt me: uitvoering: Oracle Java SE

(op telefoon is het geen doen om via feedback topic te werken)

Op dit item kan niet meer gereageerd worden.