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
Fail to reformat by JDK17 for Pattern Matching for instanceof #768
IIRC, #533 is about using the appropriate JDK (JBR) for running the IDE (corresponding to your project JDK, i.e. you can't use JBR 11 to format Java 17 code), and #787 when using 2022.2.
I think this is covered by the issues @tbroyer mentioned. The formatter itself can handle these constructs, but only when running on a JVM that supports them:
java -jar google-java-format-1.15.0-all-deps.jar T.java
class T {
{
if (a instanceof String str) {
System.out.println(str);
}
}
}
Activity
MatthewRyanRead commentedon Jun 10, 2022
Reproduced in 2022.1.2 with plugin 1.15.0.0 (formatter 1.15.0) on Temurin-17.0.2+8.
https://github.com/spotify/fmt-maven-plugin and https://github.com/diffplug/spotless both appear to handle this construction perfectly, so it seems specific to the IntelliJ plugin rather than to the library generally.
tbroyer commentedon Jun 10, 2022
Is this when running IDEA itself with JDK 17 ? or only using JDK 17 as the "project JDK" ?
See #533
MatthewRyanRead commentedon Jun 11, 2022
I was using 17 as the project JDK while using the default 11 runtime for the IDE.
However, I can also reproduce this on the 2022.2 EAP version of IntelliJ, which runs on their bundled 17.0.3+7-469.3-jcef runtime at the moment.
zxeoc commentedon Jul 27, 2022
In my case, it works fine with project JDK 17 & JBR 11. It fails after I update IDEA to 2022.2, which switches to JBR 17 by default.
tbroyer commentedon Jul 27, 2022
IIRC, #533 is about using the appropriate JDK (JBR) for running the IDE (corresponding to your project JDK, i.e. you can't use JBR 11 to format Java 17 code), and #787 when using 2022.2.
cushon commentedon Aug 4, 2022
I think this is covered by the issues @tbroyer mentioned. The formatter itself can handle these constructs, but only when running on a JVM that supports them: