Skip to content

Latest commit

 

History

History
121 lines (99 loc) · 12.8 KB

File metadata and controls

121 lines (99 loc) · 12.8 KB

java-v25.0.pdf

java 25 (Sep 2025)

  • Java 22 (march 2024), java 23 (Sep 2024)
  • java 24 (march 2025), java 23 (Sep 2025)
  • removed the support for the legacy 32-bit x86 architecture from OpenJDK (final)

overview


Features Summary

✔️ language

Java Version JEP / Feature Title / Status Description Short Example / Use / Scenario
JDK 22 456 Unnamed Variables & Patterns (final) Use underscore (_) for variables or pattern elements you don’t intend to name/use (HappyCoders.eu) catch (IOException _) { … } or pattern match: if (o instanceof Point(_, y)) …
JDK 25 513 Flexible Constructor Bodies (final) Allows certain statements before calling super(...) or this(...) in a constructor (with constraints) Validation or field setup before invoking the parent constructor
JDK 25 512 CompactSourceFiles & Instance Main Methods (final) Supports writing Java programs without explicit class boilerplate; non-static main allowed; auto imports from java.base (InfoQ) 📚CompactSourceFile.java
JDK 25 507 🔸Primitive Types in Patterns, instanceof & switch Extend pattern matching, instanceof, and switch to support primitive types if (o instanceof int i) { … } or switch (x) { case int i -> … } , 📚Primitive.java
  • Module Import Declarations
import module java.base; // New 👈🏻

// Traditionally / OLD 
// dependencies in a module were only declared in :
// module-info.java 
//      - requires directives

// ---
// Scenario-1
import module java.base;
import module java.sql;

/*error:
both class java.sql.Date in java.sql and class java.util.Date in java.util match
error: reference to Date is ambiguous
*/
import java.sql.Date; //resolve /fix

✔️ language 2

Java Version JEP / Feature Title / Status Description Short Example / Use / Scenario
JDK 22 458 Launch Multi-File Source-Code Programs (final) java launcher can accept multiple .java files and compile/run on the fly (OpenJDK) java A.java B.java without pre-compilation
JDK 23 467 Markdown Documentation Comments (final) JavaDoc comments may use Markdown syntax instead of or in addition to traditional JavaDoc tags (Eclipse Foundation) /** * # Summary * Use **bold** … */
JDK 24 483 AOT/Ahead-of-Time Class Loading & Linking Preload and prelink classes to improve startup performance (Leyden / AOT cache) (InfoQ) Use AOT / CDS / class prelinking to reduce runtime class loading overhead

✔️API

✔️Concurrent / Context / Execution / GC / Runtime Features

Java Version JEP / Feature Title / Status Description Short Example / Use / Scenario
JDK 22 423 Region Pinning for G1 (final) G1 GC can pin regions referenced by native code, so GC need not pause entirely for pinned objects (BellSoft) When native code has a pointer to a Java object, GC can skip relocating that region
JDK 24 404 Generational Shenandoah (experimental) Introduces generational mode to Shenandoah GC (young/old regions) (InfoQ) Use -XX:ShenandoahGCMode=generational to operate in generational mode
JDK 24 491 Synchronize Virtual Threads without Pinning Permit use of synchronized methods with virtual threads without needing to pin threads (InfoQ) Virtual-thread code can safely use synchronized without performance penalties
JDK 24 490 ZGC: Remove Non-Generational Mode Drop support for the legacy (non-generational) mode of ZGC (InfoQ) Only generational ZGC remains in future versions
JDK 24 486 Permanently Disable Security Manager Remove legacy SecurityManager support entirely (InfoQ) Apps relying on setSecurityManager must migrate to alternative security models
JDK 25 (expected final) Generational Shenandoah (move from experimental to production) Shenandoah’s generational GC becomes production-qualified (InfoWorld) Use generational Shenandoah GC in production environments
JDK 25 509 JFR CPU-Time Profiling (experimental) Extend Java Flight Recorder to capture CPU-time profiling data (esp. on Linux) (Erik Gahlin’s Blog) Enable JFR to record method-level CPU usage, not just wall-clock events
JDK 25 (preview) Stable Values (preview) API for “stable” immutable data, treated similarly to constants, but with flexible initialization timing (OpenJDK Mailing Lists) @Stable int x = expensiveInit(); — JVM can optimize as if final

✔️Interop / Native / Memory / JNI & Unsafe

Java Version JEP / Feature Title / Status Description Short Example / Use / Scenario
JDK 22 454 Foreign Function & Memory API (final) Safe, efficient mechanism to call native functions and access off-heap memory; intended to supersede JNI (OpenJDK) Use MemorySegment, Linker, etc., to call a C function or manipulate an off-heap buffer
JDK 24 472 Prepare to Restrict JNI Add restrictions / tighten use of JNI in favor of safer interop APIs Encourage migration from JNI to the FFM API
JDK 24/25 (TBD in 25) Compact Object Headers (project Lilliput) (experimental) Reduce object header size to lower memory footprint (InfoQ) More memory-efficient representation of Java objects
JDK 25 470 PEM Encodings of Cryptographic Objects (preview) API to encode / decode keys, certs, CRLs in PEM format (for PKI interoperability) (Oracle) Load PrivateKey from PEM, output Certificate to PEM
  • PEM API (JEP 470)

    • adds support for reading and writing cryptographic keys and certificates in PEM format via standard APIs
    • This improves interoperability with OpenSSL-based systems and streamlines secure communications.
  • FFM API (Advance topic, can skip) ❌

    • Foreign Function & Memory API
    • https://www.happycoders.eu/java/foreign-function-memory-api/
    • replacement for old/slow - Java Native Interface (JNI)| FFM 4x faster.
    • makes it possible to access code outside the JVM
      • functions in libraries implemented in other programming languages
      • memory not managed by the JVM in the heap