~/talk

Java Pattern Puzzles

Talkat JNation 2025 · 2025-05-27..05-28· [java, compilers-and-language-design]
slides:none on file

Project Amber demos show concrete code (JShell plus OpenJDK JDK12/14/15/18/19/23) that adds pattern matching for instanceof, switch expressions, records, sealed classes and deconstruction; six puzzles expose surprises: JShell accepts reused variable name even though javac rejects it, guarded patterns use a contextual when token, record deconstructors forbid mixing a pattern variable with the deconstruction, sealed hierarchies let switches be exhaustive without default, and primitive promotion/boxing causes unexpected matches. Examples compile or fail exactly as shown; one JShell quirk behaves like a bug.

AI-written summary · about

  1. 0:00Introduction
  2. 0:42Pattern matching fundamentals
  3. 2:30Switch expressions in Java
  4. 5:58Records and sealed classes
  5. 10:29Pattern matching for instanceof
  6. 16:30First puzzle: variable scoping
  7. 19:06Pattern matching for switch
  8. 24:17Guarded patterns explained
  9. 25:43Confusing guarded pattern
  10. 29:15Second puzzle: pattern dominance
  11. 32:29Record patterns and deconstruction
  12. 36:03Composing patterns
  13. 38:56Unnamed pattern variables
  14. 40:20Primitive types in patterns
  15. 42:05Third puzzle: autoboxing
  16. 45:23Switch versus instanceof
  17. 46:28Fourth puzzle: primitives
  18. 47:54Primitives with switch
  19. 48:59Fifth puzzle: completeness
  20. 49:21Summary and edge cases
~/search
type to search 8,222 conferences, 162,397 speakers and 219,688 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
← →
on a talk: 5 seconds back / forward
0–9
on a talk: jump to 0%–90% of the recording
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.