Quick revision
The short answer
For application developers, the features that became final in Java 25 LTS are scoped values (JEP 506), a safer replacement for many ThreadLocal uses; flexible constructor bodies (JEP 513), which allow statements before super(...) or this(...); module import declarations (JEP 511), such as import module java.base;; compact source files and instance main methods (JEP 512) for small programs; and the key derivation function API (JEP 510) for security code. Structured concurrency was still a preview in 25, so it is not for production code yet.
What to remember
In this answer, we went through the Java 25 features an application developer is likely to use: scoped values for safe, read-only context in place of many ThreadLocals, flexible constructor bodies that allow validation and field assignment before super(...), module import declarations, compact source files with instance main methods and the IO class for small programs, and the key derivation function API for security code. We also saw that structured concurrency was still a preview in 25, while features finalised in 22 to 24 arrive with the upgrade as well.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
For application developers, the features that became final in Java 25 LTS are scoped values (JEP 506), a safer replacement for many ThreadLocal uses; flexible constructor bodies (JEP 513), which allow statements before super(...) or this(...); module import declarations (JEP 511), such as import module java.base;; compact source files and instance main methods (JEP 512) for small programs; and the key derivation function API (JEP 510) for security code. Structured concurrency was still a preview in 25, so it is not for production code yet.
Why this question is asked
Java 25 is the LTS release after 21, so it is where many teams will next adopt new language and library features. Interviewers ask this question to see whether we know which features are final and usable, and whether we can explain what each one is for rather than just name it. In this answer, we will go through each final feature with a short example and the problem it solves, and finish with what was still in preview.
1Scoped Values: Context Without ThreadLocal
A ThreadLocal stores a value per thread, and frameworks use it to pass context such as the current user or request id down a call chain without adding parameters. It has three problems: any code can change the value with set(), the value lives until someone calls remove(), which people forget, and each child thread needs a copy. With virtual threads, where we may have millions of threads, those costs matter.
A scoped value is bound for the duration of a method call and is read-only inside it. When the call returns, the binding is gone automatically.
Notice there is no set() and no remove(). The value cannot leak into the next task on the same thread, and code deeper in the call cannot overwrite it; it can only rebind it for a nested call. Scoped values are designed to be inherited cheaply by subtasks in structured concurrency, which is where they are most useful.
2Flexible Constructor Bodies
Until now, the first statement of a constructor had to be super(...) or this(...). That made simple things awkward, such as checking an argument before passing it to the parent, which needed a static helper method. Java 25 allows statements before that call, as long as they do not use the object being constructed, except to assign its fields.
Notice that the check now runs before the parent constructor does any work. The code before super(...) is called the prologue. It cannot call instance methods or read fields of this, because the object is not ready yet, but it can assign fields, which lets a subclass initialise a field before the parent constructor calls an overridden method that reads it.
3Module Imports and Compact Source Files
Module import declarations let one line import every public type that a module exports. Compact source files, together with instance main methods, let a small program skip the class declaration and public static void main(String[] args). Such a file imports java.base automatically, and the new java.lang.IO class gives simple console input and output.
Notice that these features are mainly about small programs, scripts, teaching and prototypes. They do not change how large applications are written, and a compact source file can grow into a normal class by adding the class declaration around it.
4The Key Derivation Function API
A key derivation function, KDF, turns some input key material, such as a shared secret from a key exchange, into one or more strong keys of a chosen length. TLS and many protocols use HKDF for this. Java 25 adds javax.crypto.KDF as a standard API, so we no longer need a third-party library or hand-written HMAC code for it.
| Feature | JEP | Status in 25 | Use it for |
|---|---|---|---|
| Scoped values | 506 | Final | Request context instead of ThreadLocal |
| Flexible constructor bodies | 513 | Final | Validation before super(...) |
| Module import declarations | 511 | Final | Fewer imports in small programs |
| Compact source files, instance main | 512 | Final | Scripts, teaching, prototypes |
| Key derivation function API | 510 | Final | HKDF in security code |
| Structured concurrency | 505 | Preview | Not yet in production |
Notice that the API follows the familiar getInstance pattern of the JCA, so providers can supply other algorithms later. Most application developers will meet it through libraries, but it is good to know it exists.
5What Was Still in Preview
Structured concurrency, which treats several subtasks as one unit that succeeds or fails together, reached its fifth preview in Java 25 with a reworked API, so it still needs --enable-preview and may change. Primitive types in patterns and stable values were also previews. Features that became final in releases 22 to 24 come along with 25 too, such as unnamed variables with _, the Foreign Function and Memory API, stream gatherers and Markdown documentation comments, so a team moving from 21 gets those as well.
6Follow-up questions
Should we replace every ThreadLocal with a scoped value?
Not every one. Scoped values fit context that is set once at the start of a unit of work and read below it, such as a request id or a security principal. A ThreadLocal used as a per-thread cache or for values that genuinely change during the work is a different use. Frameworks will adopt scoped values gradually, so check your framework's support before changing code that integrates with it.
Can code before super() call a method of the class?
Not an instance method on this, because the object is not initialised yet; the compiler rejects it. Static methods, local variables and the constructor's parameters are all fine, and fields of this may be assigned but not read.
Do compact source files matter for production?
Rarely for services. They make small utilities and scripts in Java much lighter, and they help teaching. In production codebases we keep normal classes.
7Conclusion
In this answer, we went through the Java 25 features an application developer is likely to use: scoped values for safe, read-only context in place of many ThreadLocals, flexible constructor bodies that allow validation and field assignment before super(...), module import declarations, compact source files with instance main methods and the IO class for small programs, and the key derivation function API for security code. We also saw that structured concurrency was still a preview in 25, while features finalised in 22 to 24 arrive with the upgrade as well.
Open with
The final features in Java 25 that I would actually use as an application developer are these. Scoped values, JEP 506, replace many ThreadLocal uses: we bind a value like a request id with ScopedValue.where(KEY, value).run(...), code below can read it but not change it, and the binding disappears when the call ends, so nothing leaks to the next task.
Then, if they want more
That fits virtual threads much better than ThreadLocal. Flexible constructor bodies, JEP 513, let us put statements before super(...) or this(...), for example validating an argument before the parent constructor runs, or assigning a field, as long as we do not use this otherwise. Module import declarations, JEP 511, let one line like import module java.base import every exported package.
Compact source files and instance main methods, JEP 512, let a small program be just a void main() method with automatic java.base imports and the IO class for console output, which is great for scripts and teaching. In security code, the key derivation function API, JEP 510, gives a standard javax.crypto.KDF, for example HKDF-SHA256.
And I would point out that structured concurrency was still in preview in 25, so I would not use it in production yet. Moving from 21 also brings what was finalised in between, like unnamed variables, the FFM API and stream gatherers.
About this answer
- Last updated
- 12 November 2026
- Versions it names
- Java 25
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
- Official documentation
- The Java Language Specification, Java SE 21, Java SE 21 API documentation
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "Which features became final in Java 25 LTS that an application developer is likely to use?": https://scrivio-interview-library.netlify.app/java/java-versions/83f357fc7c/