Skip to content

Error formatting switch blocks with arrow labels #507

Closed
@skirkpatrick

Description

@skirkpatrick

GJF gives the following error when formatting a file containing a switch statement using Java 14 arrow labels (case ... ->):

error: expected token: 'case'; generated ; instead

For example:

public class App {

  public void test(String subject) {
    switch (subject) {
      case "A" -> System.out.println("A");
      case "B" -> System.out.println("B");
    }
  }
}

GJF version: google-java-format-1.8-all-deps.jar
Java version:

openjdk version "14.0.1" 2020-04-14
OpenJDK Runtime Environment AdoptOpenJDK (build 14.0.1+7)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 14.0.1+7, mixed mode, sharing)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions