incremental language enhancements (e.g., pattern matching, records, local variable type inference) • Project Loom: Lightweight concurrency and virtual threads for improved scalability • Project Valhalla: Advanced JVM features for value types and specialized generics (performance enhancements) • Project Panama: Interfacing Java with native code (e.g., better integration with C libraries) • Project ZGC/Shenandoah: Low-latency garbage collectors for performance-critical applications.
garbage collectors for perform ance-critical applications Project Panam a Interfacing Java w ith native code (e.g., better integration w ith C libraries) Project Valhalla Advanced JVM features for value types and specialized generics (perform ance enhancem ents) Project Loom Lightw eight concurrency and virtual threads for im proved scalability Project Am ber Sm all, increm ental language enhancem ents (e.g., pattern m atching, records, local variable type inference)
Stanley, New York • More than 15 years of experience in Java • Co-lead New York Java SIG,NY and Garden State Java User Group,NJ • Part of Java in Education program at JCP • Enjoy travelling, yoga and cricket • Find me on LinkedIn, Twitter/X or Github linktr.ee
Enhancement Proposals • Preview features ◦ Experimental but final Features ◦ Opt-in Usage ◦ Evolving Design ◦ How to enable? ◦ Can be taken out! • Command Line: Use --enable-preview with javac and java. • Maven: Add the --enable-preview flag in the maven-compiler-plugin. • Gradle: Modify your build.gradle to include --enable-preview. • IDEs: Use the IDE settings to enable preview features for both compilation and running.
Introduced in Java 10 ◦ Lets the compiler infer variable types, reducing boilerplate ◦ No performance change ◦ Naming variables is more important with var usage • Local-Variable Syntax for Lambda Parameters (JEP 323): ◦ Introduced in Java 11 ◦ Using var in lambda parameters is optional and most useful when you need to add annotations or modifiers ◦ If you use var for one parameter, you must use it for all parameters in the lambda expression
395): ◦ Introduced in Java 14 as preview, finalized in Java 16 ◦ Data Classes ◦ Immutable and Final ◦ Ideal for Data Transfer Objects • Sealed Classes (JEP 360, JEP 397, JEP 409): ◦ Introduced in Java 15 as preview, finalized in Java 17 ◦ Controlled Inheritance ◦ Improved Code safety ◦ Enhanced Pattern Matching
JEP 378): ◦ Introduced in Java 13 as preview, finalized in 15 ◦ Multi-line String Simplification ◦ Improved Readability ◦ Automatic Formatting • String Templates (JEP 430, JEP 459, JEP 465-Withdrawn): ◦ Only exist as preview feature in Java 21 and 22 ◦ Not available in Java 23! ◦ Simplified String Concatenation ◦ Improved Safety ◦ Enhanced Readability
JEP 361): ◦ Introduced in Java 12 as preview, finalized in Java 14 ◦ Simplified Syntax ◦ Return Values ◦ Exhaustiveness Checking • Pattern Matching for instanceof (JEP 305, JEP 375, JEP 394): ◦ Introduced in Java 14 as preview, finalized in Java 16 ◦ Eliminates Casting ◦ Improves Readability ◦ Safer Type Handling
420, 427, 433, 441): ◦ Introduced in Java 17 as preview, finalized in Java 21 ◦ Simplifies Control Flow ◦ Type-Safe Exhaustiveness ◦ Works with Sealed Types • Primitive Types in Patterns, instanceof, and switch (JEP 455): ◦ Introduced in Java 23 as preview ◦ Unified Type Handling ◦ Enhanced Switch Expressions ◦ Reduced Boilerplate
JEP 440): ◦ Introduced in Java 19 as Preview, finalized in Java 21 ◦ Pattern Matching for Data Decomposition ◦ Enhanced Readability ◦ Works with instanceof and switch • Unnamed Patterns and Variables (JEP 443, JEP 456): ◦ Introduced in Java 21 as Preview, finalized in Java 22 ◦ Ignore Unneeded Data ◦ Cleaner Syntax ◦ Enhanced Pattern Matching Flexibility