Add recipes to migrate boxed primitive constructors deprecated in Java 9 #332
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What's changed?
Added a set of Refaster recipes to deal with boxed primitive constructors that were deprecated in Java 9.
What's your motivation?
https://rewriteoss.slack.com/archives/C01A843MWG5/p1698430647117759?thread_ts=1698429230.444949&cid=C01A843MWG5
Anything in particular you'd like reviewers to focus on?
Unless I missed something, I think I covered all deprecated constructors except
new Float(double) -> Float.valueOf((float) double)
. Due to how Refaster generates the code, I end up in a situation like the following:Refaster Template
Generated Code Error
Therefore I was only able to cover
new Float(Double) -> new Float(Double.floatValue())
instead.Is there any way to force a real primitive in this line via Refaster (or use e.g.: a String-format template somehow)?
Do we need to make a separate imperative recipe just to cover the
Float(double)
edge case?Anyone you would like to review specifically?
@timtebeek 🙏
Have you considered any alternatives or workarounds?
We could use imperative recipes but the change seems simple enough that the Refaster usage seems to be justified and seems to avoid a lot of repeated boilerplate code.
Any additional context
Checklist
./gradlew licenseFormat