You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Indentation level difference after case between Java 11 and 17 #643
The 1.11.0 formatter running on a Java 17 JDK indents some lines further than the same formatter running on a Java 11 JDK. The problem can be seen with long expressions in switch cases.
Input file:
public class Foo {
static final int VERBOSE_WORDY_AND_LENGTHY_ONE = 1;
static final int VERBOSE_WORDY_AND_LENGTHY_TWO = 2;
static final int VERBOSE_WORDY_AND_LENGTHY_FOUR = 4;
public static int fn(int x) {
switch (x) {
case VERBOSE_WORDY_AND_LENGTHY_ONE | VERBOSE_WORDY_AND_LENGTHY_TWO | VERBOSE_WORDY_AND_LENGTHY_FOUR:
return 0;
default:
return 1;
}
}
}
Java 11 format: (build 11.0.9.1+1)
public class Foo {
static final int VERBOSE_WORDY_AND_LENGTHY_ONE = 1;
static final int VERBOSE_WORDY_AND_LENGTHY_TWO = 2;
static final int VERBOSE_WORDY_AND_LENGTHY_FOUR = 4;
public static int fn(int x) {
switch (x) {
case VERBOSE_WORDY_AND_LENGTHY_ONE
| VERBOSE_WORDY_AND_LENGTHY_TWO
| VERBOSE_WORDY_AND_LENGTHY_FOUR:
return 0;
default:
return 1;
}
}
}
(10 spaces before each |)
Java 17 format: (build 17-ea+31-2664)
public class Foo {
static final int VERBOSE_WORDY_AND_LENGTHY_ONE = 1;
static final int VERBOSE_WORDY_AND_LENGTHY_TWO = 2;
static final int VERBOSE_WORDY_AND_LENGTHY_FOUR = 4;
public static int fn(int x) {
switch (x) {
case VERBOSE_WORDY_AND_LENGTHY_ONE
| VERBOSE_WORDY_AND_LENGTHY_TWO
| VERBOSE_WORDY_AND_LENGTHY_FOUR:
return 0;
default:
return 1;
}
}
}
(14 spaces before each |)
The indentation is similarly inconsistent with or without the -a flag.
Activity
Fix indentation of case statements on JDK 17
Fix indentation of case statements on JDK 17
pburka commentedon Oct 19, 2021
Given that Java 17 has been GA for over a month now, any chance of a new GJF release that's Java 17 compatible?
Fix indentation of case statements on JDK 17
Fix indentation of case statements on JDK 17
Fix indentation of case statements on JDK 17
Fix indentation of case statements on JDK 17