JDK 21 설치

JEP 440: Record Patterns (openjdk.org)

Pattern matching and records

// As of Java 16
record Point(int x, int y) {}

static void printSum(Object obj) {
    if (obj instanceof Point p) {
        int x = p.x();
        int y = p.y();
        System.out.println(x+y);
    }
}
// As of Java 21
static void printSum(Object obj) {
    if (obj instanceof Point(int x, int y)) {
        System.out.println(x+y);
    }
}

Nested record patterns

// As of Java 16
record Point(int x, int y) {}
enum Color { RED, GREEN, BLUE }
record ColoredPoint(Point p, Color c) {}
record Rectangle(ColoredPoint upperLeft, ColoredPoint lowerRight) {}

(문자열 포매팅 가능\\{})

spring.threads.virtual.enabled=true
./gradlew nativeCompile

Untitled

All together now: Spring Boot 3.2, GraalVM native images, Java 21, and virtual threads with Project Loom,