Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace Reference.clone() with new constructor in Java 11 migration #510

Merged
merged 9 commits into from
Jul 11, 2024

Conversation

ranuradh
Copy link
Contributor

What's changed?

This PR contains recipe:
org.openrewrite.java.migrate.ReferenceCloneMethod
This rule:
image

What's your motivation?

The custom recipe, replaces the calls to java.lang.ref.Reference.clone() with a constructor call passing in the referent and reference queue as parameters.

Anyone you would like to review specifically?

@timtebeek
@cjobinabo

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

@ranuradh ranuradh requested review from cjobinabo and timtebeek July 10, 2024 13:08
@timtebeek timtebeek added the recipe Recipe requested label Jul 10, 2024
AnuRam123 and others added 4 commits July 10, 2024 09:12
…dTest.java

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
…dTest.java

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@timtebeek timtebeek changed the title Java 11 recipe remove ReferenceCloneMethod Replace Reference.clone() with new constructor in Java 11 migration Jul 11, 2024
Copy link
Contributor

@timtebeek timtebeek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the new recipe @AnuRam123 ; good to see you back!

I've made some changes to your recipe to also clear out the fully qualified types, and remove the type casts that are no longer necessary with the new constructors. Hope you agree!

@timtebeek timtebeek merged commit 9c99820 into openrewrite:main Jul 11, 2024
2 checks passed
@ranuradh
Copy link
Contributor Author

Thanks @timtebeek yes I was looking into TypeCast and wasn't sure how to go about it. This recipe is now perfect!

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.

3 participants