Two new draft pattern matching JEPs

Tagir Valeev amaembo at
Thu Feb 18 12:52:59 UTC 2021


Thank you!

There's a sample in Nested Record and Array Patterns draft:

static void printColorOfUpperLeftPoint(Object o) {
    if (o instanceof Rectangle(ColoredPoint ul, ColoredPoint lr)){
        if (ul instanceof ColoredPoint(Point p, Color c)) {

It looks like here, the nested pattern "ul instanceof
ColoredPoint(Point p, Color c)" is total. I thought that there's idea
to prohibit total patterns with instanceof (at least total type test
patterns are already prohibited). Please correct me if I'm wrong.

With best regards,
Tagir Valeev.

On Thu, Feb 18, 2021 at 7:33 PM Gavin Bierman <gavin.bierman at> wrote:
> Dear all,
> The next steps in adding pattern matching to Java are coming! I have drafted two new JEPs:
> - Nested Record and Array Patterns:
> - Pattern Matching for switch:
> We split them up to try to keep the complexity down, but we might decide to merge them into a single JEP. Let me know what you think.
> Draft language specs are under way - I will announce those as soon as they are ready.
> Comments welcome as always!
> Thanks,
> Gavin

More information about the amber-spec-experts mailing list