Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Different formatting for switch comments depending on JDK version #1127

Closed
msridhar opened this issue Jul 31, 2024 · 1 comment · Fixed by #1129
Closed

Different formatting for switch comments depending on JDK version #1127

msridhar opened this issue Jul 31, 2024 · 1 comment · Fixed by #1129

Comments

@msridhar
Copy link
Contributor

Input:

class TestSwitch {
  enum TestEnum {
    ONE,
    TWO
  }

  void test(TestEnum e) {
    switch (e) {
      case ONE:
        System.out.println("one");
        break;
        // test comment
      default:
        System.out.println("default");
    }
  }
}

If I run GJF 1.23.0 on JDK 11 for this input, the formatting is unchanged. But, if I run it on JDK 17 or higher, the indentation of the // test comment line is changed to match that of default:. Is this expected behavior? Seems related to f7543b2.

@cushon
Copy link
Collaborator

cushon commented Aug 5, 2024

Thanks, that's a bug. The JDK 17+ behaviour is the expected one after f7543b2

copybara-service bot pushed a commit that referenced this issue Aug 5, 2024
This was introduced by f7543b2, which only updated the logic for for JDK 17+.

Fixes #1127

PiperOrigin-RevId: 659562426
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants