openrewrite / openrewrite/rewrite-spring

Spring Framework 6.1 - Add `-parameters` compiler flag if missing

Open
#467 0 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

recipe
Dominant language
Java
Stars
403
Forks
149
Avg merge
2h 33m
Merged PRs (30d)
10

Description

What problem are you trying to solve?

Spring Framework 6.1 made this change: https://github.com/spring-projects/spring-framework/wiki/Upgrading-to-Spring-Framework-6.x?secureweb=Teams#parameter-name-retention

Looking at the discussion behind that change (https://github.com/spring-projects/spring-framework/pull/29531), it seems that the Spring Team expects that ~all Spring Framework apps are using the -parameters option already, by convention. And now in 6.1, many features break if the project is not using that compiler option.

What precondition(s) should be checked before applying this recipe?

  • Check that project is not using Spring Boot Starter Parent as a Maven Parent (or similar for Gradle), as this applies the relevant -parameters config already
    • Maybe transitively check the parent hierarchy for anything setting the -parameters option instead of hardcoding spring-boot-starter-parent
  • Check that the project doesn't already set -parameters in its own config

Describe the situation before applying the recipe

Describe the situation after applying the recipe

See the examples in the Spring Release Notes up above

Have you considered any alternatives or workarounds?

A collection of recipes could attempt to tweak source code to avoid using every feature which relies on parameter names (eg always explicitly give the name in every @PathVariable), but this would be a large scope and seems inconsistent with Spring conventions.

Any additional context

Are you interested in contributing this recipe to OpenRewrite?

Maybe; probably not in the short term

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the recipe implementations and tests for Maven and Gradle compiler configuration, then compare the Spring Framework release notes and the referenced Spring pull request. The recipe should add -parameters only when existing parent or project configuration does not already provide it, with tests covering both Maven and Gradle cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
build-system
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.