Primitive type patterns - an alternative approach (JEP 507)

Stephen Colebourne scolebourne at joda.org
Wed Oct 15 06:34:44 UTC 2025


In the vein of JEP feedback, I believe it makes sense to support
primitive types in pattern matching, and will make sense to support
value types in the future. And I can see the great work that has been
done so far to enable this.

Unfortunately, I hate the proposed syntactic approach in JEP 507. It
wasn't really clear to me as to *why* I hated the syntax until I had
enough time to really think through what Java does in the area of
primitive type casts, and why extending that as-is to pattern matching
would IMO be a huge mistake.

(Please note that I fully grasp the pedagogical approach wrt
instanceof defending an unsafe cast, but no matter how much it is
repeated, I don't buy it, and I don't believe it is good enough by
itself.)

To capture my thoughts, I've written up how Java's current approach to
casts leads me to an alternative proposal - type conversion casts, and
type conversion patterns:
https://tinyurl.com/typeconvertjava1

thanks
Stephen


More information about the amber-dev mailing list