Title: Google Java Format fails on complex switch expressions with Java 21 · Issue #983 · google/google-java-format · GitHub
Open Graph Title: Google Java Format fails on complex switch expressions with Java 21 · Issue #983 · google/google-java-format
X Title: Google Java Format fails on complex switch expressions with Java 21 · Issue #983 · google/google-java-format
Description: Version 1.18.1 formatter throws an exception when trying to handle code like this: return switch (obj1) { case null -> obj2 == null; case T1 myT1 when obj2 instanceof T1 otherT1 -> myT1.equalsStrict(otherT1); // exception ^ at the when (...
Open Graph Description: Version 1.18.1 formatter throws an exception when trying to handle code like this: return switch (obj1) { case null -> obj2 == null; case T1 myT1 when obj2 instanceof T1 otherT1 -> myT1.equalsStric...
X Description: Version 1.18.1 formatter throws an exception when trying to handle code like this: return switch (obj1) { case null -> obj2 == null; case T1 myT1 when obj2 instanceof T1 otherT1 -> myT1.equal...
Opengraph URL: https://github.com/google/google-java-format/issues/983
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Google Java Format fails on complex switch expressions with Java 21","articleBody":"Version 1.18.1 formatter throws an exception when trying to handle code like this:\r\n```java\r\n return switch (obj1) {\r\n case null -> obj2 == null;\r\n case T1 myT1 when obj2 instanceof T1 otherT1 -> myT1.equalsStrict(otherT1);\r\n // exception ^ at the when (69:46 in the original source)\r\n case T2 myT2 when obj2 instanceof T2 otherT2 -> T2.isDeepEquals(myT2, otherT2);\r\n default -> obj1.equals(obj2);\r\n };\r\n```\r\n\r\nThe exception is:\r\n```\r\nStep 'google-java-format' found problem in 'src/test/java/com/example/test/acceptance/ExpectedResult.java':\r\n69:46: error: : or -> expected\r\ncom.google.googlejavaformat.java.FormatterException: 69:46: error: : or -> expected\r\n at com.google.googlejavaformat.java.FormatterException.fromJavacDiagnostics(FormatterException.java:51)\r\n at com.google.googlejavaformat.java.Formatter.format(Formatter.java:149)\r\n at com.google.googlejavaformat.java.Formatter.getFormatReplacements(Formatter.java:273)\r\n at com.google.googlejavaformat.java.Formatter.formatSource(Formatter.java:247)\r\n at com.google.googlejavaformat.java.Formatter.formatSource(Formatter.java:213)\r\n at com.diffplug.spotless.glue.java.GoogleJavaFormatFormatterFunc.apply(GoogleJavaFormatFormatterFunc.java:65)\r\n at com.diffplug.spotless.FormatterFunc.apply(FormatterFunc.java:32)\r\n at com.diffplug.spotless.FormatterStepImpl$Standard.format(FormatterStepImpl.java:82)\r\n at com.diffplug.spotless.FormatterStep$Strict.format(FormatterStep.java:103)\r\n at com.diffplug.spotless.Formatter.compute(Formatter.java:246)\r\n at com.diffplug.spotless.PaddedCell.calculateDirtyState(PaddedCell.java:203)\r\n at com.diffplug.spotless.PaddedCell.calculateDirtyState(PaddedCell.java:190)\r\n at com.diffplug.gradle.spotless.SpotlessTaskImpl.processInputFile(SpotlessTaskImpl.java:105)\r\n at com.diffplug.gradle.spotless.SpotlessTaskImpl.performAction(SpotlessTaskImpl.java:89)\r\n\u003cgradle stack trace elided>\r\n```","author":{"url":"https://github.com/bmeier-pros","@type":"Person","name":"bmeier-pros"},"datePublished":"2023-10-30T14:20:22Z","url":"https://github.com/google/google-java-format/issues/983"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:18419910-3eb0-4b63-ad3e-cf7a9711bfd0 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C980:16DABC:13E88C:1AC3B3:6AFBDDDC |
| html-safe-nonce | b1c98502f5a2dc7b759b804a833758bc68e12a2ae4e92f392f00d09d48d84c41 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDOTgwOjE2REFCQzoxM0U4OEM6MUFDM0IzOjZBRkJERERDIiwidmlzaXRvcl9pZCI6Ijg5NjQwMTgzNzI2MDE0Mzc2NjAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | d542d5d7943af5ce244e7bcfe3f8064f7648fd3b37ea235f4d9eaf9edd1cf7cc |
| hovercard-subject-tag | issue:1968491217 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/google/google-java-format/983/issue_layout |
| twitter:image | https://opengraph.githubassets.com/c8759eefc1b8528a2bd93faef8f29cf0ed8082fa2520405a7f38994e9fd8d5b9/google/google-java-format/issues/983 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/c8759eefc1b8528a2bd93faef8f29cf0ed8082fa2520405a7f38994e9fd8d5b9/google/google-java-format/issues/983 |
| og:image:alt | Version 1.18.1 formatter throws an exception when trying to handle code like this: return switch (obj1) { case null -> obj2 == null; case T1 myT1 when obj2 instanceof T1 otherT1 -> myT1.equalsStric... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | bmeier-pros |
| hostname | github.com |
| expected-hostname | github.com |
| None | 744d4381b1c4dbd6d8736c7d7e5bbe7dc11217584e457a3555020c631764e8ec |
| turbo-cache-control | no-preview |
| go-import | github.com/google/google-java-format git https://github.com/google/google-java-format.git |
| octolytics-dimension-user_id | 1342004 |
| octolytics-dimension-user_login | |
| octolytics-dimension-repository_id | 35448780 |
| octolytics-dimension-repository_nwo | google/google-java-format |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 35448780 |
| octolytics-dimension-repository_network_root_nwo | google/google-java-format |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | df859c48a4c8b4c0009c19bb4e82101aacb4b998 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width