"Ich benutze Java 8" ist Vergangenheit. Java 25 wurde offiziell veröffentlicht: Oracle bietet acht Jahre Updates und 18 neue Funktionen wurden online gestellt.
Once the king of programming languages, Java's current update speed is beyond the reach of countless developers. In the blink of an eye, its version has reached 25.
It's worth noting that Java 25, recently released by Oracle, is the latest Long-Term Support (LTS) version. Looking back, the previous LTS version was JDK 21, launched in September 2023. Compared with regular six - month versions, LTS versions will receive maintenance and support for a longer period. JDK 25 will receive at least 8 years of Oracle Premier commercial support.
In simple terms, according to Oracle's plan, JDK 25 will provide free security and performance updates on a quarterly basis before September 2028, following the NFTC (No - Fee Terms and Conditions) license. After that, updates will continue under the Java SE OTN (Oracle Technology Network License Agreement) license, which is expected to last until at least September 2033.
Here, we'll provide a brief explanation. Compared with NFTC, OTN is a stricter free - use license. It allows developers to use Java SE for free in development and testing. However, if they want to use it in the production environment or large - scale commercial deployment in the long term, they need to purchase commercial support from Oracle. In other words, OTN is more like a "free for development, pay for commercial use" model.
According to Oracle's announcement, Java 25 brings a total of 18 feature updates, 5 of which Oracle claims can assist in AI development.
Next, let's take a look at these new features that are worth developers' attention.
Language Improvements
At the language level, JDK 25 brings the third preview of primitive type pattern matching, expanding the support of instanceof and switch for primitive types. Developers can directly operate on primitive types in various pattern contexts, which makes Java syntax more consistent and expressive, and reduces the risks caused by forced type - casting. This feature was first proposed in JDK 23 and followed up in JDK 24, and it is still in the preview stage.
In terms of modularity, module import declarations allow developers to import all packages output by an entire module at once, reducing a large number of repetitive import declarations. This design is particularly friendly to beginners and can simplify the use of third - party libraries.
Simplifying source code files and instantiating the main method will also be finalized in JDK 25. It allows beginners to write Java programs in the simplest way without having to understand complex language features at the beginning. For experienced developers, this mechanism is also convenient for writing small programs, reducing unnecessary boilerplate code.
Flexible constructor bodies will also be finalized in JDK 25. This feature allows developers to write safe statements (such as field initialization) before explicitly calling super(...) or this(...), making the constructor more natural in expression and ensuring that objects are safely initialized before being made visible externally.
Oracle JDK 25 Library Updates
Structured concurrency enters its fifth preview in JDK 25. It manages a group of related concurrent tasks as a whole, simplifying error handling and task cancellation, and improving reliability and observability. In the new version, the creation method of StructuredTaskScope has been changed to a static factory method, simplifying the writing of common use cases.
Scoped values will finally be finalized in JDK 25. This feature allows methods to share immutable data between the same thread and its child threads. It is lighter than traditional thread - local variables and easier to reason about and understand. After multiple rounds of previews (from JDK 21 to JDK 24), it will be officially determined in JDK 25, and there are also minor adjustments to the API. For example, the ScopedValue.orElse method will no longer accept null parameters.
Stable Values, as a preview feature, provide a more flexible way to handle immutable data. They are considered constants by the JVM, enabling performance optimizations similar to final fields while allowing more freedom in the initialization timing. This can not only improve application startup performance but also ensure the safe initialization of data in a multi - threaded environment.
The Vector API enters the incubation stage again, making its tenth appearance in the JDK. This API aims to enable Java to utilize the CPU's vector instructions, making it more efficient than scalar calculations. In JDK 25, it has two important improvements. First, the implementation of underlying mathematical functions has been migrated from the C++ code inside the HotSpot JVM to calling native mathematical libraries through the External Function and Memory API, improving maintainability. Second, on supported x64 CPUs, addition, subtraction, multiplication, division, square root, and multiply - accumulate operations of the Float16 type can now be automatically vectorized. In addition, VectorShuffle has also added interoperability with MemorySegment.
Security Libraries
In terms of security and encryption, JDK 25 previews a concise API for PEM (Privacy - Enhanced Mail) encrypted object encoding. With this feature, developers can more conveniently convert between common PEM formats and Java encryption objects, such as keys, certificates, and certificate revocation lists. In the past, the Java platform did not have an easy - to - use PEM encoding and decoding API. One of the goals of the new feature is to improve usability and also support conversion to and from standard binary formats, including PKCS#8 (private keys), X.509 (public keys, certificates, and revocation lists), and PKCS#8 v2.0 (encrypted private keys and asymmetric keys).
In the field of encryption, JDK 25 will officially provide the Key Derivation Function API. It supports deriving new keys from existing secret keys and data through algorithms, which is particularly important for future security environments facing quantum computing. This API supports algorithms such as HMAC - based key derivation functions (HKDF) and Argon2, and can also be used in key encapsulation mechanisms (such as ML - KEM), hybrid key exchange in TLS 1.3, and advanced protocols such as hybrid public - key encryption. It was previewed in JDK 24 and is now officially launched in JDK 25.
Enhancements in Security and Performance
Another feature that makes its official debut is Compact Object Headers. It first appeared as an experimental feature in JDK 24 and has now proven to perform well in terms of stability and performance. This feature compresses the size of object headers in the HotSpot JVM from the original 96 to 128 bits to 64 bits (on 64 - bit architectures), thereby reducing heap memory usage, improving deployment density, and data locality.
To further improve the application startup experience, JDK 25 also introduces improvements to ahead - of - time compilation command - line and ahead - of - time method analysis. The former makes it easier for developers to create ahead - of - time (AOT) caches, thereby accelerating the startup speed of Java applications while avoiding the addition of complex workflows and maintaining a simple and consistent user experience. The latter allows the just - in - time compiler (JIT) to immediately generate efficient native code at application startup by reusing the method execution information collected during the previous run of the application, without waiting for the accumulation of new performance data. This means that the application can "warm up" faster without modifying the existing code or framework. In fact, this feature is an extension of the AOT cache mechanism in JDK 24.
In terms of performance analysis, JDK 25 makes important enhancements to JDK Flight Recorder (JFR) by introducing the CPU time analysis function. JFR is a performance monitoring and analysis tool for the JDK. The new version uses the CPU timer of the Linux kernel to generate more accurate CPU time analysis reports for Java programs, helping developers optimize the efficiency of applications running on Linux. This feature is currently experimental and may be extended to other platforms in the future. It's worth mentioning that there are a total of three enhancements related to JFR in JDK 25. In addition to CPU time analysis, there are also cooperative sampling and method execution timing and tracing functions.
At the same time, JDK 25 also improves the stability of JDK Flight Recorder (JFR) and launches the cooperative sampling function. When asynchronously sampling Java thread stacks, the new mechanism will choose to perform stack traversal at safepoints, thereby reducing sampling errors and making performance analysis results more reliable.
Moreover, JDK 25 adds a new method execution timing and tracing function to JDK Flight Recorder (JFR). This means that developers can record the execution time and call stack information of specific methods without bytecode instrumentation and without modifying the source code. Methods can be specified remotely through command - line parameters, configuration files, the jcmd tool, or even the Java Management Extensions (JMX) API. With this capability, developers can more easily locate performance bottlenecks, optimize code, and even trace the root causes of bugs.
In terms of garbage collection, JDK 25 upgrades the Generational Shenandoah Garbage Collector from an experimental feature to an official feature. This collector was first previewed in JDK 24 and has been significantly improved in terms of stability and performance. Its goal is to improve the sustainable throughput of Java programs, handle the pressure caused by sudden load spikes, and optimize memory utilization. Some developers have tested this collector in high - load scenarios and the feedback has been positive. In fact, the generational Shenandoah was originally planned to be launched in JDK 21 in 2023 but was postponed due to immaturity.
JDK 25 will also officially remove support for 32 - bit x86. This porting version was marked as deprecated in JDK 24, and after its complete removal, the OpenJDK community can focus on promoting new features and optimizations, such as the evolution of the External Function and Memory API.
Finally, although not on the official feature list, Oracle also revealed that JDK 25 has also improved String performance. The String::hashCode method can now benefit from the compiler's constant folding optimization, resulting in a significant performance boost when strings are used as immutable Map keys.
"You release as you like, I'll stick with Java 8" is a thing of the past!
Regarding the official release of Java 25, although many netizens continue to joke, "You release as you like, I'll stick with Java 8", according to the latest data on Java usage released by the Azul organization this year, developers are most concerned about the Long - Term Support (LTS) versions. Java 17 has quietly become the most widely used version, followed closely by Java 21. As for the newly launched Java 25, whether it will gradually replace the old versions and become the new mainstream like its predecessors remains to be seen over time.
Official announcement: https://www.oracle.com/news/announcement/oracle-releases-java-25-2025-09-16/
https://www.infoworld.com/article/3846172/jdk-25-the-new-features-in-java-25.html
This article is from the WeChat official account "CSDN", compiled by Su Mi, and published by 36Kr with permission.