The Art of Java Language Pattern Matching
summary
Java adds concrete pattern features: instanceof pattern lets the compiler bind and flow-scope variables (JDK14); switch expressions accept type and null cases and must be exhaustive; records + sealed classes create algebraic types usable in record deconstruction (JDK19) and guarded patterns with the contextual when keyword; JDK21 introduces unnamed pattern variables (_) to ignore parts during nested deconstruction. The talk demonstrates compiler checks for pattern dominance, shows why named-record-patterns were dropped (ambiguity), and notes array deconstruction is proposed but not yet implemented.
AI-written summary · about
chapters (12)
- 0:00Welcome
- 1:07Pattern matching basics
- 5:22Switch expressions evolution
- 10:35Java records and ADTs
- 16:55Sealed classes rules
- 20:27Pattern matching with instanceof
- 28:53Pattern matching in switch
- 34:49Guarded patterns
- 41:35Pattern matching for records
- 48:00Named record patterns removal
- 51:52Future array deconstruction
- 53:18Summary
related talks
29mThe Art of Java Language Pattern Matching
46mThe Art of Java Type Patterns
46mThe Art of Java Type Patterns
55mThe Art of Java Language Pattern Matching
50mPattern Matching in Java Deep Dive
22mPattern Matching
39mPattern Matching: Small Enhancement or Major Feature?
54mPattern Matching in Java: Past, Present, Future
