Movatterモバイル変換


[0]ホーム

URL:


Java SE 24( JSR 399)
Public Review Specification
Iris Clark
2025/1/10 00:07 +0000[959e5bdfff6d]
Copyright © 2025 Oracle and/or its affiliates · All Rights Reserved ·License

This Specification defines version 24 of the Java Platform, Standard Edition (“Java SE 24”). The Reference Implementation of this Specification is the Java Development Kit, version 24 (“JDK 24”).

Contents
1Summary
2Structure
3Definitions
4Component JSR Specifications
5Features
6APIs previewed
7Modules
8APIs removed
9APIs proposed for removal
Annexes
A1Complete API Specification
A2API Specification differences
A3Java Language &Virtual Machine Specifications
A4JAR File Specification
A5Java AWT Native Interface (JAWT) Specification & Guide
A6Java Debug Wire Protocol (JDWP)
A7Java Native Interface (JNI) Specification
A8Java Object Serialization Specification
A9Java Remote Method Invocation(RMI) Specification
A10Java Security StandardAlgorithm Names
A11JVM Tool Interface (JVM TI)
1
Summary  

This release continues the evolution of the Platform to ensure the broadest possible success of the core Java technology. It re-previews four language features, which are updated with further refinements based on experience and feedback: flexible constructor bodies; module import declarations; primitive types in patterns,instanceof, andswitch; and simple source files and instancemain methods. This release standardizes a Class-File API and stream gatherers. It also adds implementations of two quantum-resistant module-lattice-based algorithms (ML-KEM and ML-DSA). It previews a key derivation function API, which may be used to create cryptographically strong keys. This release re-previews two features: a structured concurrency API, which simplifies multithreaded programming, and a scoped value API, which enables sharing of immutable data within and across threads. In preparation for a future release that ensures integrity by default, JNI and Foreign Function and Memory API (FFM) are aligned to issue runtime warnings during JNI loading and linking by default. Finally, this release permanently disables the Security Manager in preparation for removal in a future release.

2
Structure  

This document directly specifies API features, enhancements, clarifications, and bug fixes. It also specifies features by reference to other Specifications which are revised in Maintenance Releases of existing JSRs. The specifications of these changes are contained in two accompanying documents:Annex 1 is the complete Java SE 24 API Specification andAnnex 2 is an annotated API specification showing the exact differences relative to Java SE 23. Informative background for these changes may be found in the list of approved Change Specification Requests for this release.

This Specification includes the Java SE 24 Editions ofThe Java Language Specification andThe Java Virtual Machine Specification inAnnex 3. The Java SE 24 Editions contain all corrections and clarifications made since the Java SE 23 Editions, as well as additions for new features. Annex 3 also presents changes toThe Java Language Specification andThe Java Virtual Machine Specification in connection with preview language features in Java SE 24.

This Specification includes the Java SE 24 versions of additional narrative specifications in Annexes 4 — 11. The Java SE 24 versions contain all corrections and clarifications made since the Java SE 23 versions, as well as additions for new features.

The Final Release of this Specification is expected to include all of the currently described features and updates; however, further changes may be forthcoming. For example, the Expert Group could determine that a feature is not yet be ready for standardization.

3
Definitions  

Changes to the Java SE Platform Specification are categorized as either features or enhancements. Afeature is, roughly speaking, a change of which at least one of the following statements is true:

Any addition that is not a feature is considered anenhancement.

There is, obviously, room for judgment when interpreting this definition. In order to maximize the visibility of Platform revisions we generally tend to consider borderline items to be features rather than enhancements.

4
Component JSR Specifications  

Some Component JSR Specifications previously incorporated into the Platform are still available separately or have significant Specifications themselves. Changes to their Specifications are therefore made in separate Maintenance Releases. The following existing component JSRs may have Maintenance Releases. These will be incorporated by reference before the Final Release of this Specification as necessary:

JSR 199: Java Compiler API [MR 8]
JSR 221: JDBC 4.0 API Specification [MR 4]
JSR 269: Pluggable Annotation-Processing API [MR 18]

Each Component JSR Specification, or revision thereto, may be related to one or more features in the detailed list below.

5
Features  

Work on features in the Java SE 24 Reference Implementation is organized in terms of JDK Enhancement Proposals (JEPs). Each feature description gives a link to the corresponding JEP document as a convenience, but that document is not a normative part of this Specification. Some features are included in the Java SE 24 Reference Implementation on apreview basis, to gain exposure before achieving permanent status in a later release of the Java SE Platform.

Summary 

LibrariesClass-File API
Prepare to Restrict the Use of JNI
Scoped Values (Fourth Preview)
Stream Gatherers
Structured Concurrency (Fourth Preview)
LanguageFlexible Constructor Bodies (Third Preview)
Module Import Declarations (Second Preview)
Primitive Types in Patterns, instanceof, and switch (Second Preview)
Simple Source Files and Instance Main Methods (Fourth Preview)
SecurityKey Derivation Function API (Preview)
Permanently Disable the Security Manager
Quantum-Resistant Module-Lattice-Based Digital Signature Algorithm
Quantum-Resistant Module-Lattice-Based Key Encapsulation Mechanism
Libraries
Class-File API

Provide a standard API for parsing, generating, and transforming Java class files.

Prepare to Restrict the Use of JNI

Issue warnings about uses of theJava Native Interface (JNI) and adjust theForeign Function & Memory (FFM) API to issue warnings in a consistent manner. All such warnings aim to prepare developers for a future release that ensuresintegrity by default by uniformly restricting JNI and the FFM API. Application developers can avoid both current warnings and future restrictions by selectively enabling these interfaces where essential.

Scoped Values (Fourth Preview)

Introducescoped values, which enable a method to share immutable data both with its callees within a thread, and with child threads. Scoped values are easier to reason about than thread-local variables. They also have lower space and time costs, especially when used together with virtual threads (JEP 444) and structured concurrency (JEP 480). This is apreview API.

Stream Gatherers

Enhance theStream API to support custom intermediate operations. This will allow stream pipelines to transform data in ways that are not easily achievable with the existing built-in intermediate operations.

Structured Concurrency (Fourth Preview)

Simplify concurrent programming by introducing an API forstructured concurrency. Structured concurrency treats groups of related tasks running in different threads as a single unit of work, thereby streamlining error handling and cancellation, improving reliability, and enhancing observability. This is apreview API.

Language
Flexible Constructor Bodies (Third Preview)

In constructors in the Java programming language, allow statements to appearbefore an explicit constructor invocation, i.e.,super(..) orthis(..). Thestatements cannot reference the instance under construction, but they caninitialize its fields. Initializing fields before invoking another constructormakes a class more reliable when methods are overridden. This is apreviewlanguage feature.

Module Import Declarations (Second Preview)

Enhance the Java programming language with the ability to succinctly import allof the packages exported by a module. This simplifies the reuse of modularlibraries, but does not require the importing code to be in a module itself.This is apreview language feature.

Primitive Types in Patterns, instanceof, and switch (Second Preview)

Enhance pattern matching by allowing primitive types in all pattern contexts,and extendinstanceof andswitch to work with all primitive types. This is apreview language feature.

Simple Source Files and Instance Main Methods (Fourth Preview)

Evolve the Java programming language so that beginners can write their firstprograms without needing to understand language features designed for largeprograms. Far from using a separate dialect of the language, beginners can writestreamlined declarations for single-class programs and then seamlessly expandtheir programs to use more advanced features as their skills grow. Experienceddevelopers can likewise enjoy writing small programs succinctly, without theneed for constructs intended for programming in the large. This is apreviewlanguage feature.

Security
Key Derivation Function API (Preview)

Introduce an API for Key Derivation Functions (KDFs), which are cryptographic algorithms for deriving additional keys from a secret key and other data. This is apreview API.

Permanently Disable the Security Manager

The Security Manager has not been the primary means of securing client-side Java code for many years, it has rarely been used to secure server-side code, and it is costly to maintain. We therefore deprecated it for removal in Java 17 viaJEP 411 (2021). As the next step toward removing the Security Manager, we will revise the Java Platform specification so that developers cannot enable it and other Platform classes do not refer to it. This change will have no impact on the vast majority of applications, libraries, and tools. We will remove the Security Manager API in a future release.

Quantum-Resistant Module-Lattice-Based Digital Signature Algorithm

Enhance the security of Java applications by providing an implementation of thequantum-resistant Module-Lattice-Based Digital Signature Algorithm (ML-DSA).Digital signatures are used to detect unauthorized modifications to data and toauthenticate the identity of signatories. ML-DSA is designed to be secureagainst future quantum computing attacks. It has been standardized by the UnitedStates National Institute of Standards and Technology (NIST) inFIPS 204.

Quantum-Resistant Module-Lattice-Based Key Encapsulation Mechanism

Enhance the security of Java applications by providing an implementation of thequantum-resistant Module-Lattice-Based Key-Encapsulation Mechanism (ML-KEM). Keyencapsulation mechanisms (KEMs) are used to secure symmetric keys over insecurecommunication channels using public key cryptography. ML-KEM is designed to besecure against future quantum computing attacks. It has been standardized by theUnited States National Institute of Standards and Technology (NIST) inFIPS 203.

Preview features A preview feature is a new feature of the Java language, Java Virtual Machine, or Java SE API that is fully specified, fully implemented, and yet impermanent. Preview features must possess the following properties:

Preview features may be removed in a future release, or upgraded to permanent features of the Java SE Platform.

The Java SE API consists solely of Java APIs, but the complete Java SE Platform includes non-Java APIs, such asJNI andJVM TI, and language-independent protocols, such asJDWP andJava Object Serialization. A preview feature may include changes to non-Java APIs and language-independent protocols.

Implementations of this Specification must:

Additional details about preview features, including a description of a preview feature’s life cycle and the relationship of preview features in the Java language to preview features in the Java SE API, are available inJEP 12Preview Features.

This section may be compared tothe corresponding section that appeared in Java SE 18.

Restricted methods Various methods in the Java SE API allow Java code to interoperate with resources outside the Java runtime in such a way that the runtime cannot prove correct or safe use of the resources. These methods, which are provided because of their high utility, are specified as having the potential to crash the Java runtime or corrupt memory. They are known asrestricted methods.

All methods in the Java SE API that are not restricted areunrestricted. Given the potential danger of restricted methods, developers should use restricted methods only when no suitable functionality is available in unrestricted methods. To encourage developers to seek unrestricted alternatives to restricted methods, the following rule applies:

In addition,native methods can cause arbitrary undefined behavior, including JVM crashes. Such problems cannot be prevented by the Java runtime, nor do they provoke exceptions for Java code to catch. Given the potential danger ofnative methods, the following rule applies:

An Implementation may provide a means to invoke its run-time system with (1) all restricted methods treated as unrestricted when invoked from code specified to the run-time system, and (2)native methods treated as if they are already bound if declared in code specified to the run-time system.

If the run-time system is invoked in this way, then by definition there are no restricted methods for the specified code to invoke, and nonative methods in the specified code that are not bound. Therefore, no warnings are issued during the execution of such code.

If code other than that specified to the run-time system either invokes a restricted method or declares anative method that is bound, the Implementation may give a signal other than a warning issued on the standard error stream.

(The Reference Implementation allows the user to specify code in which (1) the invocation of restricted methods will be treated as the invocation of unrestricted methods, and (2)native method declarations will be treated as already bound. This is achieved via the command-line option--enable-native-access=M, whereM is a comma-separated list of modules. The special operandALL-UNNAMED indicates every unnamed module, which includes code on the class path. When the
--enable-native-access option is present, any invocation of restricted methods from, or binding ofnative methods in, code outside the listed modules will cause, at most, one warning to be issued per module.)

(The Reference Implementation can identify when code invokes restricted methods and whennative methods are bound. These actions are calledrestricted operations. The identification of restricted operations is enabled via the command-line option--illegal-native-access=X, whereX isallow,warn, ordeny. A value ofallow means that all restricted operations will proceed silently;warn will cause a warning to be issued at most once per module if code performs restricted operations; anddeny will cause anIllegalCallerException to be thrown for every restricted operation. Future revisions of this Platform Specification are expected to makedeny the default and eventually remove bothallow andwarn.)

The list of restricted methods may be found in theRestricted Methods section of theAPI Specification.

Compared to Java SE 23, this Specification designates the following pre-existing methods as restricted:

This section may be compared tothe corresponding section that appeared in Java SE 23.

Preparing for removal of finalization An Implementation must support the finalization of objects, as described inThe Java Language Specification, section 12.6. However, the Java SE 18 Platform Specificationdeprecates finalization, for removal. To aid preparations for the removal of finalization, an Implementation may provide a means to invoke its run-time system with finalization disabled. If finalization is disabled, the effect is that the Java Virtual Machine never invokes an object’s finalizer before the storage for the object is reclaimed by the garbage collector. An Implementation must not, by default, disable finalization.

(The Reference Implementation provides the ability to disable finalization via the command-line option--finalization=disabled.)

Future revisions of this Platform Specification are expected to disable finalization by default and, eventually, to remove finalization from the Java Language Specification.

6
APIs previewed  

The list of Java APIs which are preview features may be found in thePreview API section of theAPI Specification. They are disabled by default at compile time and run time.

(The Reference Implementation provides the ability to enable the entire set of preview features via the command-line option
--enable-preview tojavac and thejava launcher.)

No non-Java APIs or language-independent protocols were added to the Java SE Platform by this Platform Specification.

Preview features may be removed in a future release, or upgraded to permanent features of the Java SE Platform.

7
Modules  

Amodule is a named set of packages designed for reuse. A specification governed by the JCP definesstandard packages, and may group them into one or morestandard modules.

This Specification groups the standard packages of the Java SE Platform into 21 standard modules, which we refer to asthe Java SE modules. The name of a Java SE module always starts with the string"java.". The complete list of such modules is:

java.base
java.compiler
java.datatransfer
java.desktop
java.instrument
java.logging
java.management
java.management.rmi
java.naming
java.net.http
java.prefs
java.rmi
java.scripting
java.se (aggregator)
java.security.jgss
java.security.sasl
java.sql
java.sql.rowset
java.transaction.xa
java.xml
java.xml.crypto

Compared to Java SE 23, this Specification does not add or remove any modules.

The module graph The Java SE modules depend upon each other as stated in their specifications, which are part of the overallAPI Specification. The corresponding complete Java SE module graph has too many edges to be displayed easily in visual form; here is thetransitive reduction of the directed acyclic graph, in which redundant edges are omitted (click to enlarge):

java.se Module Graph

Here is how to read this visualization of the module graph:

A module is a Java SE module — that is, considered part of the Java SE Platform Specification — if and only if it is a standard module reachable from thejava.se module.

Relaxing strong encapsulation As an aid to migration, previous versions of this Specification permitted an Implementation to provide a means to invoke its run-time system with one or more packages of one or more of its modules open to code in all unnamed modules,i.e., to code on the class path. This is no longer permitted.

(The Reference Implementation provided this capability via the command-line option--illegal-access=permit.)

An Implementation must not relax the strong encapsulation of any of its modules, either by default or upon request. That is, its run-time system must not behave as if some packages in the Implementation’s modules are open when they are not open according to their module declarations. A package, or an entire module, is open to code in all unnamed modules if and only if:

This section may be compared tothe corresponding section that appeared in Java SE 16.

Incorporated subsections This Specification incorporates the following subsections by reference from the Java SE 9 Platform Specification (JSR 379),“Modules”:

8
APIs removed  

The following API was removed from the Java SE Platform by this Platform Specification. The number in parentheses indicates the Java SE Platform Specification which first proposed its removal.

Fields

9
APIs proposed for removal  

The following APIs were proposed for removal from the Java SE Platform by the Platform Specifications forJava SE 10,Java SE 13,Java SE 16,Java SE 17,Java SE 18,Java SE 19,Java SE 20,Java SE 21, andJava SE 23. They are not removed in this release of the Java SE Platform. They continue to be eligible for removal in a future release.

Packages 

Classes 

Exceptions 

Methods 

Constructors 

The following APIs are proposed for removal from the Java SE Platform by this Platform Specification. They are annotated as@Deprecated withforRemoval=true, following the convention established byEnhanced Deprecation. This makes them eligible for removal in a future release.

Classes  

Methods  

Additional details about deprecations, including potential alternatives, may be found in theDeprecated API section of theAPI Specification. Migration away from deprecated APIs is strongly encouraged.


[8]ページ先頭

©2009-2025 Movatter.jp