The Art of Java Type Patterns
summary
Covers concrete language changes: pattern matching for instanceof (preview in JDK 14, final in JDK 16) removes redundant casts and uses flow scoping; pattern matching for switch (JEP 406 in JDK 17) adds null labels, guarded cases, dominance and completeness checks and shifts to a when guard in upcoming JDK 19 (JEP 427); records (JDK 14) enable record deconstruction patterns and composition with var and proposed array patterns; sealed classes (JDK 15) make exhaustive switches practical. Code examples show compiling rules and where the compiler rejects unreachable cases.
AI-written summary · about
chapters (27)
- 0:00Intro
- 0:30Modern Java
- 3:17Pattern Matching Fundamentals
- 4:20Pattern Types
- 6:12Switch Expressions
- 7:34Switch Statement
- 8:18Switch Expression (JDK 12)
- 10:10Simple Java Data Class
- 11:53Records (JDK 14)
- 12:19Records Additional Details
- 13:47Java Inheritance
- 14:23Sealed Classes (JEP 360)
- 16:16Using The instanceof Operator
- 17:24Pattern Matching For instanceof (JDK 14)
- 20:30Flow Scoping For Binding Variables Scope of local variable runs from its declaration until the end of the block in which it is dedared
- 23:06Pattern Matching For instanceof Puzzler
- 24:23JDK 18 jshell
- 29:57Pattern Matching for switch (Completeness)
- 31:19Guarded Patterns (JDK 18)
- 33:10Guarded Patterns (JDK 19)
- 33:29Pattern Dominance
- 36:38Pattern Matching instanceof And Records
- 37:24Pattern Matching For Records (JEP 405)
- 38:17Patterns Are Composable
- 40:08Patterns And Local Variable Type Inference
- 41:57Pattern Matching For Arrays
- 44:01Azul Zulu Builds of OpenJDK • Enhanced build of Open source code
related talks
46mThe Art of Java Type Patterns
29mThe Art of Java Language Pattern Matching
56mThe Art of Java Language Pattern Matching
39mPattern Matching: Small Enhancement or Major Feature?
55mThe Art of Java Language Pattern Matching
54mPattern Matching in Java: Past, Present, Future
50mPattern Matching in Java Deep Dive
25mBrewing Patterns in Java - An Informal Primer
