spring-io / spring-javaformat

Apache License 2.0
795 stars 110 forks source link

Support Java 21 #406

Closed mandrean closed 5 months ago

mandrean commented 6 months ago

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");
        }
    }
}
philwebb commented 6 months ago

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

philwebb commented 6 months ago

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

luccaflower commented 5 months ago

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

wilkinsona commented 5 months ago

Thanks, @luccaflower.