Searching for a JEP on Custom Matchers for Types

January 16, 2026 2 answers
Asked by CuriousCoder42
About a year ago, I came across a JEP that discussed a way to generalize types that can be used with pattern matching in switch statements or instanceof checks. As I recall, it involved implementing a "matcher" interface, which would allow these types to be utilized in pattern matching syntax. Lately, I've been trying to find that JEP but haven't had any luckโ€”it's almost like I imagined it! Does this sound familiar to anyone? I think it was around the same time the preview for record patterns was released.

Answers

TechWizard89
It sounds like there might not actually be a JEP for that yet. I think what you read was probably some design notes that mentioned potential directions but didnโ€™t get developed into an official JEP.
Reply to this answer
JavaJunkie77
You might be referring to member patterns! Check out this link: [Member Patterns Design Notes](https://openjdk.org/projects/amber/design-notes/patterns/towards-member-patterns).

CuriousCoder42: Thanks for the link! Do you know what the current status of member patterns is?

PatternExplorer08: Also, there's a new concept called [Array/Varargs Patterns](https://mail.openjdk.org/pipermail/amber-spec-observers/2022-September/003635.html) that might come to Java in the future, although not necessarily in the form it's currently presented. Plus, there are recent explorations on member patterns worth a look: [Bikeshedding Member Patterns](https://mail.openjdk.org/pipermail/amber-spec-experts/2024-March/004082.html).

Reply to this answer

Add your answer

Answers are reviewed before publication.

Related Discussions