Skip to content

Improve Java 17 and Java 21 switch expression tests#822

Merged
jevanlingen merged 3 commits intomainfrom
improve-switch-expression-migrations-java-17-tests
Aug 13, 2025
Merged

Improve Java 17 and Java 21 switch expression tests#822
jevanlingen merged 3 commits intomainfrom
improve-switch-expression-migrations-java-17-tests

Conversation

@jevanlingen
Copy link
Copy Markdown
Contributor

@jevanlingen jevanlingen commented Aug 13, 2025

What's changed?

Nothing. Only the tests are restructured between Java 17 and Java 21.

What's your motivation?

The recipes target constructs related to the enhanced switch feature introduced in newer Java versions. While the recipes never intends to produce uncompilable code, they can transform code into forms that are only valid starting from Java 21 (for example, a multi-label case that includes null and default).

To ensure tests accurately reflect the language features available in each version, I either split up the test file or used the version function to inform the reader this setup is only possible with Java 21.

Validation

To ensure I am certain, I tested every test case with a Java 17 project.

Checklist

  • I've added unit tests to cover both positive and negative cases
  • I've read and applied the recipe conventions and best practices
  • I've used the IntelliJ IDEA auto-formatter on affected files

@jevanlingen jevanlingen requested a review from Jenson3210 August 13, 2025 07:31
@jevanlingen jevanlingen self-assigned this Aug 13, 2025
@jevanlingen jevanlingen added the recipe Recipe requested label Aug 13, 2025
@github-project-automation github-project-automation bot moved this to In Progress in OpenRewrite Aug 13, 2025
jevanlingen and others added 2 commits August 13, 2025 09:47
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>
@jevanlingen jevanlingen moved this from In Progress to Ready to Review in OpenRewrite Aug 13, 2025
@jevanlingen jevanlingen merged commit b884cfb into main Aug 13, 2025
2 checks passed
@jevanlingen jevanlingen deleted the improve-switch-expression-migrations-java-17-tests branch August 13, 2025 08:21
@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

recipe Recipe requested

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

2 participants