Pattern Matching for Java
summary
Project Amber features are shown with concrete Java versions and code effects: Java 16 brings the instanceof pattern that removes casts and introduces flow-scoped binding variables; Java 17/preview adds switch expressions with guarded patterns, a null case label, and dominance rules; records and sealed classes (the records and sealed classes combo) enable exhaustive matching so switches can omit defaults. Examples include record deconstruction and array patterns; the talk demos how these reduce boilerplate and catch bugs earlier.
AI-written summary · about
chapters (17)
- 0:00Introduction to talk
- 0:25Project Amber overview
- 2:31Records and sealed types
- 7:23What is pattern matching
- 9:13Why learn pattern matching
- 12:04Problem with old instance of
- 14:23Instance of with pattern matching
- 15:25Binding variables explained
- 17:09Switch statements evolution
- 18:32Switch expressions benefits
- 19:12Handling null in switch
- 20:14Guarded patterns
- 21:17Pattern label dominance
- 22:01Exhaustive switch checks
- 23:27Types of pattern matching
- 24:09Record patterns demo
- 25:46Q&A session
related talks
55mThe Art of Java Language Pattern Matching
54mPattern Matching in Java: Past, Present, Future
43mJava Language Futures, Spring 2023 Edition
46mThe Art of Java Type Patterns
56mThe Art of Java Language Pattern Matching
39mPattern Matching: Small Enhancement or Major Feature?
29mThe Art of Java Language Pattern Matching
50mPattern Matching in Java Deep Dive
