Java future calls for boosts with records, primitives, classes

Oracle’s latest Java language ambitions are expected to offer improvements in records, classes, primitives, and arrays. As part of these plans, pending features not now marked for a future release of the language are under consideration to officially be part of Java.

In a March 17 presentation at the JavaOne conference in Redwood City, Calif., Oracle’s Dan Smith, senior developer in the company’s Java platform group, cited planned features for inclusion, but added that these features may change or go away instead. New Java language features include preserving the feel of Java and minimizing disruption, making it easier to work with immutable data, being more declarative and less imperative, and minimizing the seams between different features. Reducing the “activation energy” for Java also was cited as a theme.

Among the features under consideration is value classes and objects, a Java Enhancement Proposal (JEP), which calls for enhancing the Java platform with value objects: class instances that have only final fields and lack object identity. Created in August 2020 and updated this month, this proposal is intended to allow developers to opt-in to a programming model for domain values in which objects are distinguished solely by the values of their fields, much as the int value 3 is distinguished from the int value 4. Other goals of this proposal include supporting compatible migration of existing classes that represent domain values to this programming model, and maximizing the freedom of the JVM to store domain values to improve memory footprint, locality, and garbage collection efficiency.

The derived record creation JEP in preview, meanwhile, would provide a concise means to create new record values derived from existing record values. The proposal also is intended to streamline the declaration of record classes by eliminating the need to provide explicit wither methods, which are the immutable analog of setter methods. Records are immutable objects, with developers frequently creating new records from old records to model new data. Derived creation streamlines code by deriving a new record from an existing record, specifying only the components that are different, according to the proposal, created in November 2023 and marked as updated in April 2024.

Also cited by Smith were the enhanced primitive boxing JEP, which is a feature in preview, and the primitive types in patterns, instanceof, and switch JEP, a feature actually undergoing its fourth preview in JDK 26. Enhanced primitive boxing, created in January 2021 and marked as updated in November 2025, uses boxing to support language enhancements that treat primitive types more like reference types. Among goals is allowing boxing of primitive values when they are used as the “receiver” of a field access, method invocation, or method reference. Also on the agenda for this JEP is supporting primitive types as type arguments, implemented via boxing at the boundaries with generic code. Unboxed return types would be allowed when overriding a method with a reference-typed return. The primitive types feature, meanwhile, calls for enhancing pattern matching by allowing primitive types in all pattern contexts and by extending instanceof and switch to work with all primitive types. This feature was created in June 2025 and last updated in December 2025.

For arrays, plans under consideration involve declarative array creation expressions, final arrays, non-null arrays, and covariant primate arrays. Declarative array creation covers capabilities including having a lambda to compute initial values. With final arrays, components cannot be mutated and must be declaratively initialized. Covariant primitive arrays can treat an int[] as a non-null Integer[]. Boxes can be accessed as needed.

Go to Source

Author: