Skip to content

Conversation

jevanlingen
Copy link
Contributor

What's changed?

All switch expression recipes are now located within the UpgradeToJava21 recipe.

What's your motivation?

Though you can partly use switch expression already in Java 17, there are still parts missing (e.g. sealed classes) or in an unexpected state.

Maintaining these recipes across multiple Java versions proved to be error-prone and cumbersome, requiring detailed knowledge of which features are supported in each release. For example, see:

To simplify maintenance and reduce potential issues, the decision was made to perform the full switch expression migration only for Java 21 and above. See also:

@jevanlingen jevanlingen requested a review from timtebeek August 13, 2025 11:56
@jevanlingen jevanlingen self-assigned this Aug 13, 2025
@jevanlingen jevanlingen added recipe Recipe requested java 21+ labels Aug 13, 2025
@github-project-automation github-project-automation bot moved this to In Progress in OpenRewrite Aug 13, 2025
@github-project-automation github-project-automation bot moved this from In Progress to Ready to Review in OpenRewrite Aug 13, 2025
github-actions[bot]

This comment was marked as outdated.

jevanlingen and others added 3 commits August 13, 2025 14:34
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@timtebeek timtebeek merged commit 5aabf01 into main Aug 13, 2025
2 checks passed
@timtebeek timtebeek deleted the move-all-switch-expression-recipes-to-java21-migration branch August 13, 2025 13:11
@github-project-automation github-project-automation bot moved this from Ready to Review to Done in OpenRewrite Aug 13, 2025
mergify bot added a commit to robfrank/linklift that referenced this pull request Sep 2, 2025
…15.0 to 3.16.0 [skip ci]

[//]: # (dependabot-start)
⚠️ \*\*Dependabot is rebasing this PR\*\* ⚠️
Rebasing might not happen immediately, so don't worry if this takes some time.
Note: if you make any changes to this PR yourself, they will take precedence over the rebase.
---
[//]: # (dependabot-end)
Bumps [org.openrewrite.recipe:rewrite-migrate-java](https://github.com/openrewrite/rewrite-migrate-java) from 3.15.0 to 3.16.0.
Release notes

*Sourced from [org.openrewrite.recipe:rewrite-migrate-java's releases](https://github.com/openrewrite/rewrite-migrate-java/releases).*

> 3.16.0
> ------
>
> What's Changed
> --------------
>
> * Fixed validation.xml in jakarta-ee-10.yml by [`@​daniel-skovenborg`](https://github.com/daniel-skovenborg) in [openrewrite/rewrite-migrate-java#834](https://redirect.github.com/openrewrite/rewrite-migrate-java/pull/834)
> * Adding `jakarta.servlet:jakarta.servlet-api` explicitly when the `javax.servlet:javax.servlet-api` it is trying to migrate from was only available transitively. by [`@​steve-aom-elliott`](https://github.com/steve-aom-elliott) in [openrewrite/rewrite-migrate-java#835](https://redirect.github.com/openrewrite/rewrite-migrate-java/pull/835)
> * Drop Joda-Time recipes extracted to rewrite-joda by [`@​timtebeek`](https://github.com/timtebeek) in [openrewrite/rewrite-migrate-java#836](https://redirect.github.com/openrewrite/rewrite-migrate-java/pull/836)
> * Adopt `InlineMethodCalls` from `openrewrite/rewrite` by [`@​timtebeek`](https://github.com/timtebeek) in [openrewrite/rewrite-migrate-java#837](https://redirect.github.com/openrewrite/rewrite-migrate-java/pull/837)
> * AddJaxbRuntime should use `overrideManagedDependency=true` by [`@​timtebeek`](https://github.com/timtebeek) in [openrewrite/rewrite-migrate-java#838](https://redirect.github.com/openrewrite/rewrite-migrate-java/pull/838)
>
> New Contributors
> ----------------
>
> * [`@​daniel-skovenborg`](https://github.com/daniel-skovenborg) made their first contribution in [openrewrite/rewrite-migrate-java#834](https://redirect.github.com/openrewrite/rewrite-migrate-java/pull/834)
>
> **Full Changelog**: <openrewrite/rewrite-migrate-java@v3.15.1...v3.16.0>
>
> v3.15.1
> -------
>
> What's Changed
> --------------
>
> * Update with rewrite 8.60.2
> * Improve Java 17 and Java 21 switch expression tests by [`@​jevanlingen`](https://github.com/jevanlingen) in [openrewrite/rewrite-migrate-java#822](https://redirect.github.com/openrewrite/rewrite-migrate-java/pull/822)
> * The JakartaEE9 upgrade process supplements the jakarta.activation upg… by [`@​ChenyuWang98`](https://github.com/ChenyuWang98) in [openrewrite/rewrite-migrate-java#820](https://redirect.github.com/openrewrite/rewrite-migrate-java/pull/820)
> * Move all switch expression recipes to Java 21 migration by [`@​jevanlingen`](https://github.com/jevanlingen) in [openrewrite/rewrite-migrate-java#824](https://redirect.github.com/openrewrite/rewrite-migrate-java/pull/824)
> * JakartaEE9 update restLet to 2.6.x by [`@​ChenyuWang98`](https://github.com/ChenyuWang98) in [openrewrite/rewrite-migrate-java#827](https://redirect.github.com/openrewrite/rewrite-migrate-java/pull/827)
> * Update jetty9 -> jetty12 as part of EE9 by [`@​ChenyuWang98`](https://github.com/ChenyuWang98) in [openrewrite/rewrite-migrate-java#826](https://redirect.github.com/openrewrite/rewrite-migrate-java/pull/826)
> * Migrate to `commons-fileupload2-jakarta` by [`@​ChenyuWang98`](https://github.com/ChenyuWang98) in [openrewrite/rewrite-migrate-java#819](https://redirect.github.com/openrewrite/rewrite-migrate-java/pull/819)
> * Update jakarta-ee-9.yml add javax.servlet.jsp update by [`@​ChenyuWang98`](https://github.com/ChenyuWang98) in [openrewrite/rewrite-migrate-java#829](https://redirect.github.com/openrewrite/rewrite-migrate-java/pull/829)
> * Create recipe for `@InlineMe` annotation replacements by [`@​timtebeek`](https://github.com/timtebeek) in [openrewrite/rewrite-migrate-java#788](https://redirect.github.com/openrewrite/rewrite-migrate-java/pull/788)
> * Use classpath from resource for Refaster by [`@​jevanlingen`](https://github.com/jevanlingen) in [openrewrite/rewrite-migrate-java#830](https://redirect.github.com/openrewrite/rewrite-migrate-java/pull/830)
> * Fix recipe reference to `AccessController` migration for Java 25 by [`@​MBoegers`](https://github.com/MBoegers) in [openrewrite/rewrite-migrate-java#832](https://redirect.github.com/openrewrite/rewrite-migrate-java/pull/832)
> * Update build Java 25 by [`@​MBoegers`](https://github.com/MBoegers) in [openrewrite/rewrite-migrate-java#833](https://redirect.github.com/openrewrite/rewrite-migrate-java/pull/833)
>
> New Contributors
> ----------------
>
> * [`@​ChenyuWang98`](https://github.com/ChenyuWang98) made their first contribution in [openrewrite/rewrite-migrate-java#820](https://redirect.github.com/openrewrite/rewrite-migrate-java/pull/820)
>
> **Full Changelog**: <openrewrite/rewrite-migrate-java@v3.15.0...v3.15.1>


Commits

* [`caec49a`](openrewrite/rewrite-migrate-java@caec49a) AddJaxbRuntime should use `overrideManagedDependency=true` ([#838](https://redirect.github.com/openrewrite/rewrite-migrate-java/issues/838))
* [`c831007`](openrewrite/rewrite-migrate-java@c831007) Update documentation examples
* [`05fa3e0`](openrewrite/rewrite-migrate-java@05fa3e0) Adopt `InlineMethodCalls` from `openrewrite/rewrite` ([#837](https://redirect.github.com/openrewrite/rewrite-migrate-java/issues/837))
* [`35ba076`](openrewrite/rewrite-migrate-java@35ba076) Drop Joda-Time recipes extracted to rewrite-joda ([#836](https://redirect.github.com/openrewrite/rewrite-migrate-java/issues/836))
* [`7d30127`](openrewrite/rewrite-migrate-java@7d30127) Adding `jakarta.servlet:jakarta.servlet-api` explicitly when the `javax.servl...
* [`cea52ed`](openrewrite/rewrite-migrate-java@cea52ed) [Auto] SDKMAN! Java candidates as of 2025-08-25T1017
* [`eb159a4`](openrewrite/rewrite-migrate-java@eb159a4) Fixed validation.xml in jakarta-ee-10.yml ([#834](https://redirect.github.com/openrewrite/rewrite-migrate-java/issues/834))
* [`0563040`](openrewrite/rewrite-migrate-java@0563040) update builds to Java 25 ([#833](https://redirect.github.com/openrewrite/rewrite-migrate-java/issues/833))
* [`0d9d736`](openrewrite/rewrite-migrate-java@0d9d736) Fix recipe reference to `AccessController` migration for Java 25 ([#832](https://redirect.github.com/openrewrite/rewrite-migrate-java/issues/832))
* [`8a16285`](openrewrite/rewrite-migrate-java@8a16285) Support `@InlineMe` annotations from any package
* Additional commits viewable in [compare view](openrewrite/rewrite-migrate-java@v3.15.0...v3.16.0)
  
[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility\_score?dependency-name=org.openrewrite.recipe:rewrite-migrate-java&package-manager=maven&previous-version=3.15.0&new-version=3.16.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)
Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.
[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)
---
Dependabot commands and options
  
You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot show  ignore conditions` will show all of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

java 21+ recipe Recipe requested

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

2 participants