-
Notifications
You must be signed in to change notification settings - Fork 852
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
NPE when formatting java file with java 21 preview features. #937
Comments
``@sureshg mind that JEP 440 removes the support for record patterns in enhanced for-loops.
My guess is that your JDK 21-ea version already dropped the support and therefore Your code uses such a for-loop here: // Record pattern in enhanced for loop
for (Point(var x, var y) : points) {
out.println("Point: (" + x + ", " + y + ")");
} |
@sormuras thanks, i missed that part. I am using the latest ea build ...
Point: (1, 2)
Point: (3, 4)
Point: (5, 6) |
Removing record pattern from for loop causes another error 67:32: error: did not generate token "("
com.google.googlejavaformat.java.FormatterException: 67:32: error: did not generate token "("
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 com.diffplug.spotless.glue.java.GoogleJavaFormatFormatterFunc.apply(GoogleJavaFormatFormatterFunc.java:57)
at com.diffplug.spotless.FormatterFunc.apply(FormatterFunc.java:32)
at com.diffplug.spotless.FormatterStepImpl$Standard.format(FormatterStepImpl.java:82) |
Pattern matching in switch isn't supported yet, I'm working on fixing that part:
|
Env
$ openjdk 21-ea 2023-09-19 OpenJDK Runtime Environment (build 21-ea+20-1677) OpenJDK 64-Bit Server VM (build 21-ea+20-1677, mixed mode, sharing) google-javaformat = "1.17.0"
Error
I am not sure for which part it's failing. I was playing the java 21 preview features. So here is the sample file used in the task
Sample
The text was updated successfully, but these errors were encountered: