René's URL Explorer Experiment


Title: Start a switch expression on the line of the declaration it initializes by abashev · Pull Request #76 · openjavaformat/open-java-format · GitHub

Open Graph Title: Start a switch expression on the line of the declaration it initializes by abashev · Pull Request #76 · openjavaformat/open-java-format

X Title: Start a switch expression on the line of the declaration it initializes by abashev · Pull Request #76 · openjavaformat/open-java-format

Description: Closes #63. Brings over palantir#1789 by Patrick Koenig, which fixes palantir#1258 and shipped in palantir-java-format 2.99.0. What changes A local variable or a field initialized with a switch expression broke after the =, with the switch indented by eight, while a plain assignment of the same switch already kept it on the line: // before int x = switch (y) { case 1 -> 1; default -> throw new IllegalStateException(); }; // after, the same shape as `x = switch (y) {` had all along int x = switch (y) { case 1 -> 1; default -> throw new IllegalStateException(); }; From upstream, with the author kept palantir#1789 by Patrick Koenig, cherry-picked as it is (git cherry-pick -x, rename detection mapped palantir-java-format/ to open-java-format/, nothing to adapt). declareOne loses its special case for an initializer that starts with switch, so the initializer takes the same level as any other, and visitCase drops the forced break after a rule case's ;. The golden ExpressionSwitch moves in the same two methods as upstream's. Added here The upstream commit rewrote the input of test1 into the new shape, so both declarations in the golden started from the target form and nothing checked the move itself. test1's input goes back to the old shape, =, a line break and the switch, with the same expected output; a field initialized with a switch expression, written in the same old shape, is added too, since no golden covered a field. Both fail on main. Checked The golden fails on main and passes with the change: assignment and the upstream test1 output pin the new shape, the restored test1 input and the new field pin the move from the old one. ./gradlew :open-java-format:test on JDK 21: 1497 tests, all green. Of the 15,747 files of the JDK 21 sources, 51 format differently: the 57 declarations initialized with a switch expression that #63 counted, every one of them. The switch moves onto the = line and its body eight columns left; in 9 of the files a case body or a throw argument that had to wrap at the deeper indent now fits on one line. Nothing else changes. The new output is stable on a second run, apart from MethodHandleImpl.java and Calendar.java, which change on a second run on main already, in the same way (a trailing comment after a call, and a block comment before a case). Version This changes the output of files that format correctly today, which the README reserves for 3.0 (#22 and #31 are in the same position). Merging is the call on that, not this PR.

Open Graph Description: Closes #63. Brings over palantir#1789 by Patrick Koenig, which fixes palantir#1258 and shipped in palantir-java-format 2.99.0. What changes A local variable or a field initialized with a switch exp...

X Description: Closes #63. Brings over palantir#1789 by Patrick Koenig, which fixes palantir#1258 and shipped in palantir-java-format 2.99.0. What changes A local variable or a field initialized with a switch exp...

Opengraph URL: https://github.com/openjavaformat/open-java-format/pull/76

X: @github

direct link

Domain: redirect.github.com

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:b31c7c76-70f4-b1c1-e2a4-7e74f046b840
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idC50C:4BEE7:99452:D6810:6AFBD8E6
html-safe-nonce8758367096adcdcdbcb8cc027724e19d0f1ad8bf4f21bf59b8aa4187c8dc007a
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDNTBDOjRCRUU3Ojk5NDUyOkQ2ODEwOjZBRkJEOEU2IiwidmlzaXRvcl9pZCI6IjIwMDkzNDAyOTE2MjE1NzQ4ODYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac95d12ea613aa912475528d8813da7e1a727c967b0c3838848a57470807ac293a
hovercard-subject-tagpull_request:4634819552
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/openjavaformat/open-java-format/pull/76/files
twitter:imagehttps://avatars.githubusercontent.com/u/214171?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/214171?s=400&v=4
og:image:altCloses #63. Brings over palantir#1789 by Patrick Koenig, which fixes palantir#1258 and shipped in palantir-java-format 2.99.0. What changes A local variable or a field initialized with a switch exp...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None18742cb872ec73544356e60359266b67aafece70c4ce008042e06227924cdd07
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/openjavaformat/open-java-format git https://github.com/openjavaformat/open-java-format.git
octolytics-dimension-user_id325177626
octolytics-dimension-user_loginopenjavaformat
octolytics-dimension-repository_id1288055459
octolytics-dimension-repository_nwoopenjavaformat/open-java-format
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forktrue
octolytics-dimension-repository_parent_id214273098
octolytics-dimension-repository_parent_nwopalantir/palantir-java-format
octolytics-dimension-repository_network_root_id214273098
octolytics-dimension-repository_network_root_nwopalantir/palantir-java-format
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release820be804f18e1ef3940bd74a00d41d73d02e2b91
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://redirect.github.com/openjavaformat/open-java-format/pull/76/files#start-of-content
https://redirect.github.com/
Sign inhttps://redirect.github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fopenjavaformat%2Fopen-java-format%2Fpull%2F76%2Ffiles
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://redirect.github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fopenjavaformat%2Fopen-java-format%2Fpull%2F76%2Ffiles
Sign uphttps://redirect.github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=openjavaformat%2Fopen-java-format
Reloadhttps://redirect.github.com/openjavaformat/open-java-format/pull/76/files
Reloadhttps://redirect.github.com/openjavaformat/open-java-format/pull/76/files
Reloadhttps://redirect.github.com/openjavaformat/open-java-format/pull/76/files
openjavaformathttps://redirect.github.com/openjavaformat
open-java-formathttps://redirect.github.com/openjavaformat/open-java-format
Codehttps://redirect.github.com/openjavaformat/open-java-format
Issues30 (30)https://redirect.github.com/openjavaformat/open-java-format/issues
Pull requests5 (5)https://redirect.github.com/openjavaformat/open-java-format/pulls
Discussionshttps://redirect.github.com/openjavaformat/open-java-format/discussions
Actionshttps://redirect.github.com/openjavaformat/open-java-format/actions
Security and qualityhttps://redirect.github.com/openjavaformat/open-java-format/security
Insightshttps://redirect.github.com/openjavaformat/open-java-format/pulse
Sign up for GitHub https://redirect.github.com/signup?return_to=%2Fopenjavaformat%2Fopen-java-format%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://redirect.github.com/login?return_to=%2Fopenjavaformat%2Fopen-java-format%2Fissues%2Fnew%2Fchoose
abashevhttps://redirect.github.com/abashev
mainhttps://redirect.github.com/openjavaformat/open-java-format/tree/main
switch-expression-declarationhttps://redirect.github.com/openjavaformat/open-java-format/tree/switch-expression-declaration
Conversation 0 https://redirect.github.com/openjavaformat/open-java-format/pull/76
Commits 2 https://redirect.github.com/openjavaformat/open-java-format/pull/76/commits
Checks 15 https://redirect.github.com/openjavaformat/open-java-format/pull/76/checks
Files changed https://redirect.github.com/openjavaformat/open-java-format/pull/76/files
Please reload this pagehttps://redirect.github.com/openjavaformat/open-java-format/pull/76/files
Start a switch expression on the line of the declaration it initializes https://redirect.github.com/openjavaformat/open-java-format/pull/76/files#top
Show all changes 2 commits https://redirect.github.com/openjavaformat/open-java-format/pull/76/files
610278d Don't break line when switch expression used in declaration assignmen… pkoenig10 Sep 23, 2026 https://redirect.github.com/openjavaformat/open-java-format/pull/76/commits/610278d5b8a676fdda99b29d66e404654830ec63
522fab5 Keep an input in the old shape in the switch expression golden abashev Sep 25, 2026 https://redirect.github.com/openjavaformat/open-java-format/pull/76/commits/522fab5495f298242c47343c8c08885ad4931adf
Clear filters https://redirect.github.com/openjavaformat/open-java-format/pull/76/files
Please reload this pagehttps://redirect.github.com/openjavaformat/open-java-format/pull/76/files
Please reload this pagehttps://redirect.github.com/openjavaformat/open-java-format/pull/76/files
JavaInputAstVisitor.java https://redirect.github.com/openjavaformat/open-java-format/pull/76/files#diff-4c56c3f402a5387ffa98b467fa35d91986b454b87e4a1b47b11da48e30272fc3
Java14InputAstVisitor.java https://redirect.github.com/openjavaformat/open-java-format/pull/76/files#diff-bbb04740c88f531f9899525cfb990c73f7319855aea4c3be6a7e41ed369f9913
ExpressionSwitch.input https://redirect.github.com/openjavaformat/open-java-format/pull/76/files#diff-b906849887e6f778bc5420c326f11ad9ed035200b31ae978946d5bde975ef164
ExpressionSwitch.output https://redirect.github.com/openjavaformat/open-java-format/pull/76/files#diff-6533b384d60150150087aac4159fab54788b7e9ff8909896ea7dbc1fe799faa0
open-java-format/src/main/java/com/palantir/javaformat/java/JavaInputAstVisitor.javahttps://redirect.github.com/openjavaformat/open-java-format/pull/76/files#diff-4c56c3f402a5387ffa98b467fa35d91986b454b87e4a1b47b11da48e30272fc3
View file https://redirect.github.com/openjavaformat/open-java-format/blob/522fab5495f298242c47343c8c08885ad4931adf/open-java-format/src/main/java/com/palantir/javaformat/java/JavaInputAstVisitor.java
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://redirect.github.com/openjavaformat/open-java-format/pull/76/{{ revealButtonHref }}
https://redirect.github.com/openjavaformat/open-java-format/pull/76/files#diff-4c56c3f402a5387ffa98b467fa35d91986b454b87e4a1b47b11da48e30272fc3
https://redirect.github.com/openjavaformat/open-java-format/pull/76/files#diff-4c56c3f402a5387ffa98b467fa35d91986b454b87e4a1b47b11da48e30272fc3
...-java-format/src/main/java/com/palantir/javaformat/java/java14/Java14InputAstVisitor.javahttps://redirect.github.com/openjavaformat/open-java-format/pull/76/files#diff-bbb04740c88f531f9899525cfb990c73f7319855aea4c3be6a7e41ed369f9913
View file https://redirect.github.com/openjavaformat/open-java-format/blob/522fab5495f298242c47343c8c08885ad4931adf/open-java-format/src/main/java/com/palantir/javaformat/java/java14/Java14InputAstVisitor.java
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://redirect.github.com/openjavaformat/open-java-format/pull/76/{{ revealButtonHref }}
https://redirect.github.com/openjavaformat/open-java-format/pull/76/files#diff-bbb04740c88f531f9899525cfb990c73f7319855aea4c3be6a7e41ed369f9913
https://redirect.github.com/openjavaformat/open-java-format/pull/76/files#diff-bbb04740c88f531f9899525cfb990c73f7319855aea4c3be6a7e41ed369f9913
...va-format/src/test/resources/com/palantir/javaformat/java/testdata/ExpressionSwitch.inputhttps://redirect.github.com/openjavaformat/open-java-format/pull/76/files#diff-b906849887e6f778bc5420c326f11ad9ed035200b31ae978946d5bde975ef164
View file https://redirect.github.com/openjavaformat/open-java-format/blob/522fab5495f298242c47343c8c08885ad4931adf/open-java-format/src/test/resources/com/palantir/javaformat/java/testdata/ExpressionSwitch.input
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://redirect.github.com/openjavaformat/open-java-format/pull/76/{{ revealButtonHref }}
https://redirect.github.com/openjavaformat/open-java-format/pull/76/files#diff-b906849887e6f778bc5420c326f11ad9ed035200b31ae978946d5bde975ef164
https://redirect.github.com/openjavaformat/open-java-format/pull/76/files#diff-b906849887e6f778bc5420c326f11ad9ed035200b31ae978946d5bde975ef164
...a-format/src/test/resources/com/palantir/javaformat/java/testdata/ExpressionSwitch.outputhttps://redirect.github.com/openjavaformat/open-java-format/pull/76/files#diff-6533b384d60150150087aac4159fab54788b7e9ff8909896ea7dbc1fe799faa0
View file https://redirect.github.com/openjavaformat/open-java-format/blob/522fab5495f298242c47343c8c08885ad4931adf/open-java-format/src/test/resources/com/palantir/javaformat/java/testdata/ExpressionSwitch.output
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://redirect.github.com/openjavaformat/open-java-format/pull/76/{{ revealButtonHref }}
https://redirect.github.com/openjavaformat/open-java-format/pull/76/files#diff-6533b384d60150150087aac4159fab54788b7e9ff8909896ea7dbc1fe799faa0
https://redirect.github.com/openjavaformat/open-java-format/pull/76/files#diff-6533b384d60150150087aac4159fab54788b7e9ff8909896ea7dbc1fe799faa0
https://redirect.github.com/openjavaformat/open-java-format/pull/76/files#diff-6533b384d60150150087aac4159fab54788b7e9ff8909896ea7dbc1fe799faa0
Please reload this pagehttps://redirect.github.com/openjavaformat/open-java-format/pull/76/files
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.