From Java 8 to Java 25: A Language Growing With Intent
Paste code from a Java 21 project into a Java 8 codebase and almost nothing will compile. Records, sealed interfaces, pattern-matching switch expressions, text blocks, none of it existed before Java 11, 14, or 17. That gap is not the result of a language committee adding features at random over a decade of six-month release cycles; it is the product of three deliberate design themes pursued in parallel: expressiveness (lambdas, records, pattern matching), safety (sealed classes, switch expressions, text blocks), and performance (ZGC, virtual threads, generational garbage collection). Understanding the intent behind each release is what separates engineers who adopt new syntax from those who genuinely write better Java.
Java 8 arrived in 2014 and changed the baseline of what idiomatic Java looked like. Lambdas and streams let you express a transformation pipeline in a single readable line instead of four nested anonymous classes. Optional gave you a type-safe way to signal absence. Those additions were not cosmetic, they shifted how Java developers thought about data flow and side effects. Every release since has built on that foundation rather than departing from it.
The expressiveness theme follows a clear arc. Java 8 gave you lambdas so you could pass behavior as data. Java 14 through 16 gave you records so you could declare data without writing behavior you didn't ask for. Java 16 and 21 layered pattern matching on top so the type system could carry information that previously lived only in casts and comments. Each step made the code closer to the problem description and further from the mechanical ceremony of making the compiler happy.
The safety theme is subtler. Sealed classes, finalized in Java 17, let the compiler know the complete set of subtypes for a given hierarchy, which in turn lets a switch expression be exhaustive without a catch-all branch. Text blocks, introduced in Java 15, removed the category of bugs that come from escaping quotes in JSON or SQL strings. These features don't prevent logic errors, but they close off whole classes of structural mistakes that previously required discipline and code review to catch.
The performance theme is the one most visible to Spring Boot users. Java 17 shipped ZGC as a production-ready garbage collector capable of sub-millisecond pauses regardless of heap size. Java 21 delivered virtual threads as a stable feature, allowing a Spring Boot application to handle tens of thousands of concurrent requests without tuning a thread pool or switching to a reactive programming model. Java 21 also introduced generational ZGC, which improves throughput by applying generational collection principles to a collector already optimized for latency.
The rest of this article walks through each Java release from 8 to 25 in order, explaining what each feature does, why the language designers made that particular choice at that particular time, and how it connects to the themes above. The Spring Boot performance section at the end shows concretely how the cumulative effect of these changes, especially virtual threads and modern GC, translates into measurable improvements for the kinds of applications most Java engineers actually run in production.
Diagram as text
flowchart LR A["Java 8 (2014)"] --> B["Expressiveness: Lambda Expressions"] A --> C["Safety: Optional"] B --> D["Java 9 (2017)"] C --> D D --> E["Java 11 (2018)"] E --> F["Performance: Flight Recorder"] E --> G["Safety: HttpClient"] F --> H["Java 17 (2021)"] G --> H H --> I["Java 21 (2023)"] I --> J["Performance: Virtual Threads"] I --> K["Expressiveness: Pattern Matching"] J --> L["Java 25 (2025)"]
Java 8: The Functional Awakening (Lambdas, Streams, and the Optional Type)#
Before Java 8, writing even a simple sort required creating an anonymous inner class. To sort a list of names alphabetically, you would instantiate a Comparator, declare its compare method, write the comparison logic inside, and close several layers of braces. Six lines, minimum, to express one idea.1 Java 8 replaced all of that with (a, b) -> a.compareTo(b). The change is not cosmetic. It reflects a genuine shift in how Java thinks about behavior: instead of wrapping it in an object with ceremony, you pass it directly.
Lambdas and the Functional Interfaces Behind Them#
Lambdas work because Java 8 formalized the concept of a functional interface, any interface with exactly one abstract method. The compiler can infer which method a lambda body is implementing, so you get concise syntax without losing the type safety Java is known for.
The four interfaces you will use constantly are Function<T,R> for transforming a value, Predicate<T> for testing a condition, Consumer<T> for operating on a value with no return, and Supplier<T> for producing a value lazily. These are not just library utilities, they are the typed slots into which lambdas fit.
The last three lines also demonstrate method references, a shorthand for lambdas that delegate to an existing method. When the lambda body is nothing but a call to a named method, the method reference form reads more clearly and signals intent without the noise of a parameter variable that exists only to be forwarded.
The Stream API#
Lambdas alone are useful, but the Stream API is where they produce their biggest payoff. A stream is a lazily evaluated pipeline: you describe a sequence of transformations and one terminal operation, and Java executes them together in a single pass.
Compare this to the equivalent imperative loop: a variable initialized to zero, a for-each, an if-statement, an increment. The stream version reads like a description of the problem rather than a manual for the machine, which makes it easier to verify at a glance.
Optional: Expressing Absence Explicitly#
Java 8 also introduced Optional<T> to reduce the null-pointer accidents that plagued earlier code. A method returning Optional<User> forces its caller to confront the possibility of absence rather than assuming the result is always present. In practice you chain .map() and .orElse() on an Optional much the same way you work with streams, keeping transformations in one readable expression instead of scattered null checks.
Taken together, lambdas, streams, and Optional shifted Java from a language where behavior lived in classes to one where behavior could be passed, composed, and returned like any other value. Every feature from Java 9 onward assumes this foundation, which is why the subsequent releases feel like natural extensions rather than unrelated additions.
Java 9-14: Incremental Expressiveness (Modules, var, Switch Expressions, Text Blocks)#
The releases between Java 9 and Java 14 often get dismissed as "minor" because no single one of them rewired the language the way lambdas did. That reading misses the point. Each feature in this window was a precise response to a specific class of problem: classpath chaos, redundant type noise, fall-through bugs, and multiline string torture. Taken together, they form a coherent push toward writing less code with fewer mistakes.
Java 9: The Module System#
Java 9's biggest contribution was Project Jigsaw, which replaced the flat classpath with an explicit module graph.1 Before modules, any class in any JAR could reach into any other JAR's internals at runtime, which made large codebases fragile and made the JDK itself difficult to trim down. A module-info.java file at the root of a module declares what the module requires and what it exports:
Code inside com.example.payments that is not listed under exports is simply invisible to other modules at compile time and at runtime. In practice, adopting modules fully is a meaningful investment, and many teams still run on the classpath for application code while benefiting from the modularized JDK, which lets jlink produce smaller custom runtimes. Either way, the enforcement boundary is there when you want it.
Java 10: Local Variable Type Inference with var#
var lets the compiler infer the type of a local variable from its initializer, removing the redundant repetition that Java historically required.1 Static typing is fully preserved; the compiler still knows the exact type and enforces it everywhere.
var is restricted to local variables with initializers, so it cannot appear in method signatures, field declarations, or anywhere the type would be ambiguous. That constraint is intentional: it keeps the clarity gains local, where the right-hand side is right there on the same line.
Java 11: Single-File Programs and String Utilities#
Java 11 quietly removed a point of friction for quick scripts and demonstrations: you can now run java HelloWorld.java directly without a separate compilation step.1 The same release added several String methods that had been conspicuously absent: isBlank() tests for empty-or-whitespace strings, lines() streams the lines of a multiline string, and strip() trims Unicode whitespace correctly, unlike the older trim(), which only handles ASCII control characters.
Java 14: Switch Expressions#
Switch expressions were previewed in Java 12 and 13 and finalized in Java 14.1 The old switch statement had two failure modes: accidental fall-through between cases, and the ceremony of declaring a variable before the switch just to capture a result. Switch expressions eliminate both.
The arrow form does not fall through. If you need a block body, the yield keyword returns the value explicitly. The compiler also enforces exhaustiveness for enum switches, so a missing case is a compile error rather than a silent null.
Java 15: Text Blocks#
Text blocks arrived as a standard feature in Java 15, and they solve a problem every Java developer has hit: multiline strings for SQL, JSON, HTML, or any structured content required painful concatenation and escape sequences.1
The compiler strips the common leading indentation automatically, so the indentation you see in the source file does not bleed into the string value. The result reads exactly like the content it represents, which makes reviews easier and mistakes less likely.
Each of these features has a narrow target: modules for encapsulation, var for local noise reduction, switch expressions for control-flow safety, text blocks for literal fidelity. None of them required you to rethink your architecture, but used consistently they meaningfully reduce the surface area where bugs hide.
Java 14-17: Safety by Design (Records, Sealed Classes, and Pattern Matching Preview)#
Before records and sealed classes existed, writing a simple data-carrier in Java required a ritual. You wanted a class to hold a name and an age, immutable, equality-comparable, printable. What you got was roughly fifty lines of boilerplate: a constructor, two getters, equals(), hashCode(), and toString(), all written by hand or generated by your IDE and then maintained forever. The intent of the class was obvious, but the code obscured it.
Records: Making Data Classes Say What They Mean#
Here is the same class written two ways.
Every line of the plain class below the header disappears. The compiler generates the canonical constructor, the accessor methods (name() and age(), not getName()), equals(), hashCode(), and toString() from the component list in the record header.1 Records are also implicitly final, so you cannot subclass them and accidentally reintroduce mutability through an override. The design choice is deliberate: a record is a statement that this type is its data, and that is all it is.
Sealed Classes: Closing the Hierarchy#
An open interface in Java can be implemented by any class, anywhere. That openness is useful for extension points, but it is a problem when you are trying to model a fixed set of variants, the shapes in a geometry library, the states in a state machine, the nodes in an AST. When the hierarchy is open, the compiler cannot tell you whether you have handled every case.
Sealed classes, finalized in Java 17, add a permits clause that names every allowed subtype.1
The compiler now knows the complete set of subtypes. That knowledge feeds directly into exhaustiveness checking: if you write a switch over a Shape and forget Triangle, the compiler rejects the code rather than letting a MatchException appear at runtime. Sealed classes and records are designed to work together, the permitted subtypes are often records because the variants carry data but have no meaningful subclass hierarchy of their own.
Pattern Matching for instanceof#
Java 16 also finalized instanceof pattern matching, which removes the cast that used to follow every type check.1
This is the preview feature that seeds the richer pattern matching arriving fully in Java 21. On its own it is a small win; in combination with sealed classes and switch expressions it becomes the foundation for exhaustive, compiler-checked dispatch over data hierarchies.
Java 17's significance extends beyond the features themselves. It became the LTS release after Java 11, which made it the baseline JVM for organizations that do not track every release, and the minimum version required by Spring Boot 3.x.1 Most production Java today runs on 17 or higher, which means records, sealed classes, and pattern matching are no longer experimental vocabulary. They are the expected way to model data.
Diagram as text
classDiagram
class Shape {
}
class Circle {
+radius
}
class Rectangle {
+width
+height
}
class Triangle {
}
Shape <|-- Circle
Shape <|-- Rectangle
Shape <|-- Triangle
note for Shape "Compiler enforces exhaustive\npattern matching over hierarchy."Java 17-21: Pattern Matching Comes of Age#
Sealed classes and records, finalized in Java 17, were always pointing toward something. Sealed classes promised exhaustive type hierarchies; records promised transparent, deconstructable data. The payoff for both arrives in Java 21, when pattern matching for switch expressions becomes a finalized feature. That combination, sealed hierarchies plus pattern switches, is where the language design starts to feel genuinely coherent.
From instanceof Chains to Pattern Switches#
Before Java 21, branching on type required a series of instanceof checks, each followed by a cast you had to write yourself. The result was repetitive and fragile. Here is the before picture with a sealed Shape hierarchy:
Java 21 replaces that chain with a switch that branches on type, deconstructs record components inline, and lets the compiler verify you have covered every permitted subtype:
The throw at the bottom is gone because the compiler knows Shape is sealed and the three cases are exhaustive. Add a fourth permitted type without updating this switch and the code does not compile. That is the sealed-classes promise actually being kept: a missing case is a compile error, not a ClassCastException at 3 AM.
You can also add guards with when, tightening a branch without nesting:
Sequenced Collections: A Quieter Win#
Java 21 also introduced sequenced collections, a smaller but genuinely useful addition. Before this, retrieving the first or last element of an ordered collection required different idioms for every type. A List gave you get(0) and get(list.size() - 1); a LinkedHashSet had no direct accessor at all; a Deque had peekFirst() and peekLast(). The new SequencedCollection, SequencedSet, and SequencedMap interfaces unify all of that with getFirst(), getLast(), addFirst(), addLast(), and reversed(). Every ordered collection type in the standard library now implements the appropriate sequenced interface, so the idiom is consistent regardless of which concrete type you are working with.
Why Java 21 Is the Upgrade Target#
Java 21 is an LTS release, which matters practically. It is the first LTS to ship virtual threads, finalized pattern matching for switch, and sequenced collections together. Teams upgrading from Java 17 do not need to chase interim releases to get these features. The sealed-classes design from the earlier section and the records design before that both reach their intended ergonomic destination here, which is why 21 has become the default upgrade target for production systems that were still running on 17.
Java 21: Virtual Threads and the End of the Blocking-Thread Bottleneck#
Every Java web server that ever struggled under load ran into the same wall. A platform thread in Java maps one-to-one to an operating system thread, and OS threads are not cheap: each one carries a stack measured in megabytes and requires the kernel to schedule it. In practice, this limits a JVM process to a few thousand concurrent threads before memory or context-switching overhead causes throughput to collapse. For a server handling 10,000 simultaneous HTTP requests where each one is mostly waiting on a database or a downstream API, that ceiling is a real problem.
The conventional solution was reactive programming: CompletableFuture chains, RxJava, or Project Reactor. Instead of blocking a thread while you wait for I/O, you return control to the thread pool immediately and register a callback for when the result arrives. The thread pool stays small; throughput stays high. The cost is that your code stops looking like code. Stack traces become useless, debugging requires mental re-assembly of which callback fired in which order, and reasoning about control flow across several asynchronous stages is genuinely hard. Brian Goetz, Java's language architect, put it plainly: reactive programming was a transitional technology, and Project Loom's goal was to make it unnecessary.
Virtual threads, finalized in Java 21 as Project Loom, resolve the tension at its root. A virtual thread is managed entirely inside the JVM, not by the operating system. Underneath, the JVM maintains a small pool of real OS threads called carrier threads. When a virtual thread performs a blocking operation, a database query, a network call, a file read, the JVM detaches it from its carrier thread and parks its lightweight continuation on the heap. The carrier thread is then free to pick up another virtual thread and run it. When the I/O completes, the original virtual thread is rescheduled onto any available carrier thread and resumes exactly where it left off2. The diagram in this section shows the carrier-thread scheduling model.
Because virtual threads live on the heap rather than consuming OS thread stacks, you can create millions of them on ordinary hardware. The code that runs on them looks completely synchronous:
That loop launches 100,000 tasks. Each one can block freely. The JVM keeps the underlying carrier pool saturated without ever spawning 100,000 OS threads.
One caveat matters here: virtual threads are designed specifically for I/O-bound blocking code, database access, network calls, file I/O. They are counter-indicated for CPU-bound work like image processing or cryptographic computation, where the thread never actually parks and the carrier thread is pinned regardless. For CPU-heavy parallelism, parallel streams or platform threads remain the right tool.
The practical payoff is that you get the scalability profile of reactive code and the readability of synchronous code. Stack traces are complete again. Debuggers work normally. A junior engineer can read the call stack without reconstructing the callback graph in their head. That is not a small gain, it is the reason Goetz called reactive a transitional technology rather than a permanent solution.
Diagram as text
flowchart LR A["HTTP Request"] -->|creates| B["OS Thread"] B -->|binds| C["Platform Thread Model"] C -->|exhausts| D["Memory"] E["Carrier Thread"] -->|multiplexes| F["Virtual Thread"] F -->|blocks| G["Park on I/O"] G -->|releases| E G -->|resumes| H["Resume after I/O"] H -->|continues| F subgraph Platform_Model A --> B --> C --> D end subgraph Virtual_Model E --> F --> G --> H end
Java 22-25: Finishing the Story (Unnamed Patterns, Primitive Patterns, and What's Still Ahead)#
Pattern matching in Java has followed a clear arc. Each release since Java 14 added one more piece: instanceof patterns, then switch patterns, then sealed-class exhaustiveness. Java 22 through 25 continue that same thread rather than starting a new one.
Unnamed patterns and variables (finalized in Java 22) solve a small but genuinely annoying problem. When pattern matching against a sealed type, you sometimes care only about the type, not the bound variable. Before Java 22, you still had to name it even if you never used it. Now you can write _ as a placeholder1:
The _ communicates intent to the reader: the type matters for dispatch, but the value doesn't matter for this branch. That is a real expressiveness gain, not cosmetic syntax sugar.
Primitive types in patterns arrived as a preview in Java 23 and continued refining through Java 24. The long-standing gap was this: generics cannot hold primitives, so List<int> has never compiled, and pattern matching inherited the same constraint. With primitive patterns in preview, you can write case int i -> in a switch on an Object, and the runtime handles unboxing for you1. That closes the last awkward corner where you'd receive a boxed Integer from a collection, pattern-match against it, and mentally translate back to an int. Because this feature is still preview as of Java 24, you need --enable-preview to compile and run it, so it isn't production-ready yet.
Java 25 is the next LTS, which means it carries outsized importance. Features that have spent several releases in preview tend to finalize here, including further refinements to structured concurrency and scoped values that complement virtual threads1. Structured concurrency, available as a preview since Java 21 via StructuredTaskScope, lets you fork child tasks and treat them as a unit, if one fails, the others are cancelled automatically:
Scoped values, the companion feature, replace ThreadLocal for virtual-thread workloads. Where ThreadLocal requires explicit cleanup and can leak across thread-pool reuse, a ScopedValue is bound for a specific call tree and disappears when that tree unwinds:
Inside handleRequest, any code can call CURRENT_USER.get() without passing the user through every method signature. Both features are still preview in Java 24; Java 25 is expected to finalize them.
Looking further ahead, Project Valhalla's value types remain the largest unfinished item on the Java roadmap. Value types would let the JVM store small objects like Point or Optional directly on the stack or inline in arrays, eliminating the heap allocation and pointer indirection that currently makes generic containers slower than primitive arrays. Valhalla is not a Java 25 deliverable, but its design has been guiding JVM internals for years, and its eventual arrival will be the last major performance gap between Java generics and native primitive code.
How Java 21+ Supercharges Spring Boot: Virtual Threads, GraalVM Native Images, and One Property#
If you have used Spring Boot 3.2 on Java 21 and wondered why throughput went up without touching a single line of business logic, the answer lives in one property:
Set that in application.properties, restart, and Tomcat swaps its platform-thread executor for a virtual-thread executor automatically. No reactive programming model, no Mono, no Flux, no callback chains. Your existing @RestController methods keep their blocking, synchronous style, and the server handles far more concurrent requests because virtual threads are parked rather than blocked when they wait on I/O. The mechanics of why that matters are covered in the virtual threads section, but the Spring integration point is worth stating plainly: one property is all it takes.
This raises the obvious question about WebFlux. Virtual threads eliminate the need for the reactive model for the overwhelming majority of I/O-bound workloads, because synchronous code on virtual threads achieves equivalent throughput while being far easier to write, read, trace, and debug. Brian Goetz has been direct about this: virtual threads were designed in large part to make reactive programming unnecessary for the performance scenarios that drove its adoption.3 That does not mean WebFlux disappears from every project. For streaming use cases like Server-Sent Events and WebSockets, for scenarios that genuinely need backpressure, or for mature reactive codebases where a migration would cost more than it gains, Reactor remains the right tool. The practical guidance for a new project in 2025 is to start with Spring MVC and spring.threads.virtual.enabled=true, and reach for WebFlux only when the use case genuinely needs what reactive streams offer.
Virtual threads address concurrency. GraalVM native images address startup time and memory. The native-image utility performs ahead-of-time compilation on your Spring Boot application, discarding unused code paths and compiling the rest into an OS- and architecture-specific binary. The result starts in a few hundred milliseconds and consumes tens of megabytes of RAM at runtime rather than hundreds.4 To produce a native binary with Maven or Gradle:
Spring Boot 3.2 with Java 21 and GraalVM is the point where three independently compelling runtime characteristics converge: high concurrency through virtual threads, fast startup through AOT compilation, and low memory through native image optimization. That convergence is what makes the combination feel like a step change rather than an incremental improvement.
The wider takeaway from Java 8 through Java 25 is not a changelog to memorize. Each release, from lambdas letting you express intent rather than ceremony, to records eliminating boilerplate data carriers, to sealed classes making illegal states unrepresentable
Sources
- The Complete Guide to Java Evolution: Java 8 to Java 25 - DEV Communitydev.to
- Project Loom & Virtual Threads: How Java 21+ Is Revolutionizing Concurrencymedium.com
- multithreading - Do Java 21 virtual threads address the main reason to switch to reactive single-thread frameworks? - Stack Overflowstackoverflow.com
- All together now: Spring Boot 3.2, GraalVM native images, Java 21, and virtual threads with Project Loom,spring.io
Keep reading
What a forward deployed engineer does, and how to prepare
A forward deployed engineer is a software engineer who works inside the customer's organization rather than inside the product team. The job is to build and ship custom solutions...
Chain of Thought or ReAct: Choosing Between Them
A support queue needs priorities. Every incoming ticket has to carry a label, P1 through P4, before it reaches a human, and you have been handed the feature. Two implementations...
How LinTS and bandits choose models in an AI gateway
An AI gateway is a single endpoint that sits in front of several language models and forwards each incoming request to one of them. Model routing is the choice it makes on every...