Amber features 2026

Remi Forax forax at univ-mlv.fr
Wed Jan 14 18:29:21 UTC 2026


----- Original Message -----
> From: "Gavin Bierman" <gavin.bierman at oracle.com>
> To: "amber-spec-experts" <amber-spec-experts at openjdk.java.net>
> Sent: Saturday, January 10, 2026 12:08:05 AM
> Subject: Amber features 2026

> Dear spec experts,
> 
> Happy New Year to you all! We thought this was a good time to share you some of
> the thinking regarding Amber features for 2026.
> 
> Currently we have one feature in preview - Primitive Patterns. We’d love to get
> more feedback on this feature - please keep kicking the tires!
> 
> We plan two new features in the near term. Draft JEPs are being worked on and
> will be released as soon as possible. But here are some brief details while you
> are waiting for the draft JEPs (in the name of efficiency, *please* let's save
> discussion for that point).
> 

[...]

> 
> ## CONSTANT PATTERNS
> 
> Another common pattern (sic) with pattern matching code is where we want to
> match a particular pattern but only for a certain value, for example:
> 
>    void code(Shape s) {
>        switch (s) {
>            case Point(var x, var y) when x == 0 && y == 0 —> { // special code for origin
>            }
>            case Point(var x, var y) -> { // code for non-origin points
>            }
>            ...
>        }
>        ...
>    }
> 
> It’s great that our pattern `switch` allows us to have separate clauses for the
> point on the origin and the other points. But it’s a shame that we have to use
> a `when` clause to specify the constant values for the origin point. This makes
> code less readable and is not what we would do if we were thinking of the code
> more mathematically. What we want to do is inline the zero values into the
> pattern itself, i.e.
> 
>    void code(Shape s) {
>        switch (s) {
>            case Point(0, 0) -> { // special code for origin
>            }
>            case Point(var x, var y) -> { // code for non-origin points
>            }
>            ...
>        }
>        ...
>    }
> 
> In other words, we’d like to support a subset of constant expressions, including
> `null`, to appear as nested patterns. We think that will lead to even more
> readable and concise pattern matching code and, from a language design
> perspective, allows us to address the somewhat awkward separation of case
> constants and case patterns, by making (almost) everything a pattern.

Hello Gavin,
healing the differences between a case constant and a case pattern is something we should continue. 

Just a question, are you proposing that
  case Point(0, 0) -> ...

is semantically equivalent to
  case Point(var x, var y) when x == 0 && y == 0 -> ...

or
  case Point(int x, int y) when x == 0 && y == 0 -> ...  // because 0 is an int

I suppose it's the former and in that case, i agree, if it's the later, i don't :)
 

> 
> We have other new Amber features in the pipeline, but we propose to prioritize
> these two features, along with the primitive patterns feature already in
> preview. Please look out for the announcements of draft JEPs when they arrive -
> as always, we value enormously your help in designing new features for our
> favorite programming language!
> 
> Wishing you a happy and successful 2026!
> Gavin

regards,
Rémi



More information about the amber-spec-experts mailing list