Skip to content

Error on unnamed variable (JDK 21 Preview) #978

Closed
@bdeneuter

Description

@bdeneuter

Unnamed variables have been added to JDK 21 as a preview feature (https://openjdk.org/jeps/443). When formatting the source code with an unnamed variable, google-java-format throws an exception.

Caused by: com.google.googlejavaformat.java.FormatterException: 102:8: error: expected token: '_'; generated  instead
        at com.google.googlejavaformat.java.Formatter.getFormatReplacements(Formatter.java:275)
        at com.google.googlejavaformat.java.Formatter.formatSource(Formatter.java:247)
        at com.google.googlejavaformat.java.Formatter.formatSource(Formatter.java:213)
        at java.base@21.0.1/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
        ... 169 more

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions