openrewrite / rewrite-migrate-java

OpenRewrite recipes for migrating to newer versions of Java.
Apache License 2.0
92 stars 65 forks source link

Recipe to Replace `sun.misc.BASE64Encoder/Decoder` with `java.util.Base64.Encoder/Decoder` #498

Closed BhavanaPidapa closed 1 week ago

BhavanaPidapa commented 2 weeks ago

What's changed?

This recipe deals with a part of this rule image

What's your motivation?

I used org.openrewrite.java.ChangeType for the recipe RemovedSunAPIs

Anyone you would like to review specifically?

@cjobinabo @timtebeek

Have you considered any alternatives or workarounds?

Since it was not possible to test the recipe. I created sample files, created a local plugin using ./gradlew publishToMavenLocal then ran it in the Java8 Sample App using mvn rewrite:dryRun

Attaching the rewrite.patch file rewrite.patch

Any additional context

This recipe covers only The sun.* APIs are unsupported, JDK-internal APIs, and may go away at any time. The sun.misc.BASE64Encoder and sun.misc.BASE64Decoder have been removed in Java SE 11. Instead, use the supported java.util.Base64 class, which was added in Java SE 8. part of the rule.

Checklist

timtebeek commented 2 weeks ago

Doesn't this overlap with this existing recipe? https://github.com/openrewrite/rewrite-migrate-java/blob/86bc2b56109aa64eb68d23c31d7565821f7ab468/src/main/java/org/openrewrite/java/migrate/UseJavaUtilBase64.java#L63-L72

cjobinabo commented 2 weeks ago

Doesn't this overlap with this existing recipe?

https://github.com/openrewrite/rewrite-migrate-java/blob/86bc2b56109aa64eb68d23c31d7565821f7ab468/src/main/java/org/openrewrite/java/migrate/UseJavaUtilBase64.java#L63-L72

Great find. The recipes do appear to overlap. We can opt for the suggestion mentioned in UseJavaUtilBase64.java instead

cjobinabo commented 1 week ago

@BhavanaPidapa feel free to close this PR when you are ready

BhavanaPidapa commented 1 week ago

With the existing custom recipe, I have tested all the test cases and results are as expected. So, I am closing this PR.