spring-io/spring-javaformat

Support Java 21

mandrean opened this issue · 4 comments

Currently fails trying to format code with Java 21 features, for example an enhanced switch with a when guard and/or multiple cases collapsed into one branch:

public record Point(int x, int y) {
}

class Cartesian {

    static void printQuadrant(Point p) {
        switch (p) {
            case Point(var x, var y) when x > 0 && y > 0 -> System.out.println("first");
            case null, default -> System.out.println("other");
        }
    }
}

We'll probably need to upgrade the eclipse version that we shade.

Actually, I wonder if #401 may have fixed this already. @mandrean have you tried the SNAPSHOT build?

Hi.
Just wanted to report that I had this issue in 0.0.41, and it appears to be resolved in 0.0.42-SNAPSHOT