-
Notifications
You must be signed in to change notification settings - Fork 78
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
Recipes for methods and classes renamed or moved when switching to Java 17 #430
Recipes for methods and classes renamed or moved when switching to Java 17 #430
Conversation
src/test/java/org/openrewrite/java/migrate/SunNetSslPackageUnavailableTest.java
Outdated
Show resolved
Hide resolved
src/test/java/org/openrewrite/java/migrate/UpgradeToJava17Test.java
Outdated
Show resolved
Hide resolved
src/test/java/org/openrewrite/java/migrate/SunNetSslPackageUnavailableTest.java
Outdated
Show resolved
Hide resolved
src/test/java/org/openrewrite/java/migrate/UpgradeToJava17Test.java
Outdated
Show resolved
Hide resolved
Hi @ranuradh ! Since you last contributed we added some automated code reviews which post comments on PRs. You'll want to apply their suggestions, or make adjustments to ensure there's no new suggestions after your last commit. |
…vailableTest.java Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
….java Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Thanks a lot @ranuradh ! @cjobinabo will you do the first round of review here? Just to be sure it's clear who's in the lead. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great start; some small touch ups to be applied in bulk from this page:
https://github.com/openrewrite/rewrite-migrate-java/pull/430/files
Other than that I think we can see this through quite quickly if @cjobinabo agrees.
src/test/java/org/openrewrite/java/migrate/SunNetSslPackageUnavailableTest.java
Outdated
Show resolved
Hide resolved
src/test/java/org/openrewrite/java/migrate/SunNetSslPackageUnavailableTest.java
Outdated
Show resolved
Hide resolved
src/test/java/org/openrewrite/java/migrate/SunNetSslPackageUnavailableTest.java
Outdated
Show resolved
Hide resolved
src/test/java/org/openrewrite/java/migrate/UpgradeToJava17Test.java
Outdated
Show resolved
Hide resolved
src/test/java/org/openrewrite/java/migrate/UpgradeToJava17Test.java
Outdated
Show resolved
Hide resolved
src/test/java/org/openrewrite/java/migrate/UpgradeToJava17Test.java
Outdated
Show resolved
Hide resolved
src/test/java/org/openrewrite/java/migrate/UpgradeToJava17Test.java
Outdated
Show resolved
Hide resolved
Co-authored-by: Tim te Beek <tim@moderne.io>
Co-authored-by: Tim te Beek <tim@moderne.io>
Co-authored-by: Tim te Beek <tim@moderne.io>
…vailableTest.java Co-authored-by: Tim te Beek <tim@moderne.io>
…vailableTest.java Co-authored-by: Tim te Beek <tim@moderne.io>
…vailableTest.java Co-authored-by: Tim te Beek <tim@moderne.io>
….java Co-authored-by: Tim te Beek <tim@moderne.io>
….java Co-authored-by: Tim te Beek <tim@moderne.io>
….java Co-authored-by: Tim te Beek <tim@moderne.io>
….java Co-authored-by: Tim te Beek <tim@moderne.io>
…vailableTest.java Co-authored-by: Tim te Beek <tim@moderne.io>
…vailableTest.java Co-authored-by: Tim te Beek <tim@moderne.io>
@timtebeek I saw all the touch ups and committed them. I took note of not using public in test classes and some formatting. This week @cjobinabo has a tech event that he is attending I think if you review and if we can merge it that will be one less review for him when he gets back. I don't think he will mind it. |
src/test/java/org/openrewrite/java/migrate/UpgradeToJava17Test.java
Outdated
Show resolved
Hide resolved
src/test/java/org/openrewrite/java/migrate/UpgradeToJava17Test.java
Outdated
Show resolved
Hide resolved
src/test/java/org/openrewrite/java/migrate/SunNetSslPackageUnavailableTest.java
Outdated
Show resolved
Hide resolved
@timtebeek and @cjobinabo can we close and merge this. I thought this was done.Thanks! |
Ah I had thought @cjobinabo would do the final check, as I'm out for the next couple weeks. |
No worries he is back and should be able to take care of it. See you after a couple of weeks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for looking into these recipes. I left a few comments about missing tests, wording updates, and issues I noticed with some recipes.
tags: | ||
- java17 | ||
recipeList: | ||
- org.openrewrite.java.ReplaceConstantWithAnotherConstant: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see a test for this recipe.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @cjobinabo since it wasnt possible to find a jar/jdk upgrade we decided to not have a test for this.. Refer to our slack conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only recipes we discussed on Slack before I left were about the removed finalize method and the removed ConstantBootstraps constructor. Perhaps this is a conversation you had with someone else. If you can't find a jar with the dependencies, I would suggest mocking one up like we have done in the past. I would rarely suggest omitting a test.
`java.util.zip.Inflater` and `java.util.zip.Deflater` as it is no longer available in Java SE 12 and later. | ||
tags: | ||
- java17 | ||
recipeList: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see a test for this recipe.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @cjobinabo since it wasnt possible to find a jar with the issue , we decided to not have a test for this.. Refer to our slack conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a conversation you and I had, or you and Tim? If you couldn't find a jar with the dependency, I would have suggested mocking one up as we have before.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was about running tests where we need an older version of Java and we cant get that to work -
so while there's no good way to unit test such recipes, you'll have to trust us that the particular case works when run on Java 8 or 11
newMethodName: end | ||
ignoreDefinition: true | ||
- org.openrewrite.java.ChangeMethodName: | ||
methodPattern: "java.util.ZipFile finalize()" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be java.util.zip.ZipFile
methodPattern: "java.util.zip.Inflater finalize()" | ||
newMethodName: end | ||
ignoreDefinition: true | ||
matchOverrides: true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we ignore definitions, we shouldn't need to do anything with overrides.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed in next commit
name: org.openrewrite.java.migrate.RemovedZipFinalizeMethods | ||
displayName: Remove `finalize` method in `java.util.zip.Zipfile`, `java.util.zip.Inflater` and `java.util.zip.Deflater` | ||
description: > | ||
The `finalize` methods in `java.util.zip.ZipFile` is replaced with `close` method and is replaced by `end` method in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
methods
should be method
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed in next commit
--- | ||
type: specs.openrewrite.org/v1beta/recipe | ||
name: org.openrewrite.java.migrate.RemovedSSLSessionGetPeerCertificateChainMethodImpl | ||
displayName: Remove `SSLSession.getPeerCertificateChain()` method |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove
to Replace
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed in next commit
--- | ||
type: specs.openrewrite.org/v1beta/recipe | ||
name: org.openrewrite.java.migrate.RemovedRMIConnectorServerCredentialTypesConstant | ||
displayName: Remove `RMIConnectorServer.CREDENTIAL_TYPES` constant |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove
to Replace
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed in next commit
name: org.openrewrite.java.migrate.RemovedRMIConnectorServerCredentialTypesConstant | ||
displayName: Remove `RMIConnectorServer.CREDENTIAL_TYPES` constant | ||
description: > | ||
This recipe replaces `RMIConnectorServer.CREDENTIAL_TYPES` constant with the `RMIConnectorServer.CREDENTIALS_FILTER_PATTERN` constant and a filter pattern. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove extra space between recipe replaces
. Also add the
before RMIConnectorServer.CREDENTIAL_TYPES
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The last bit about the pattern and a filter pattern
can be removed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed in next commit
- java17 | ||
recipeList: | ||
- org.openrewrite.java.ReplaceConstantWithAnotherConstant: | ||
existingFullyQualifiedConstantName: javax.management.remote.rmi.RMIConnectorServer.CREDENTIAL_TYPES |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CREDENTIAL_TYPES
should be CREDENTIAL_TYPE
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this rule I see the this rule flags references to the RMIConnectorServer.CREDENTIAL_TYPES constant and jmx.remote.rmi.server.credential.types string literal. The RMIConnectorServer.CREDENTIAL_TYPES constant was removed in Java SE 15. The constant can be replaced with the RMIConnectorServer.CREDENTIALS_FILTER_PATTERN constant and a filter pattern.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right. It seems like there may have been a typo in the link I looked at initially.
--- | ||
type: specs.openrewrite.org/v1beta/recipe | ||
name: org.openrewrite.java.migrate.SunNetSslPackageUnavailable | ||
displayName: Remove `com.sun.net.ssl` package |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove
to Replace
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed in next commit
@@ -527,4 +528,42 @@ void lombokBumpedGoingTo17() { | |||
) | |||
); | |||
} | |||
|
|||
@Test | |||
void removedSSLSessionGetPeerCertificateChainMethodImplTest(){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If possible, please split each recipe into its own test method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually I thought unless we had multiple cases it was better to put them in the common Test.java, I could add it to another text if u feel strongly but I went with what I saw in the file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left the earlier comment here because I thought this test method was attempting to test more than one recipe. But that actually does not appear to be the case, so nothing needs to be changed here.
name: org.openrewrite.java.migrate.RemovedZipFinalizeMethods | ||
displayName: Replace `finalize` method in `java.util.zip.Zipfile`, `java.util.zip.Inflater` and `java.util.zip.Deflater` | ||
description: > | ||
The `finalize` method in `java.util.zip.ZipFile` is replaced with `close` method and is replaced by `end` method in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this sentence, let's add the
before close
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed in next commit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some suggestions could not be made:
- src/main/java/org/openrewrite/java/migrate/maven/UpdateMavenProjectPropertyJavaVersion.java
- lines 1-0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some suggestions could not be made:
- src/main/java/org/openrewrite/java/migrate/maven/UpdateMavenProjectPropertyJavaVersion.java
- lines 1-0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Thanks again for working on this.
This PR contains 4 recipes for Java SE 17 migrations.
They are:
org.openrewrite.java.migrate.RemovedZipFinalizeMethods
org.openrewrite.java.migrate.RemovedSSLSessionGetPeerCertificateChainMethodImpl
org.openrewrite.java.migrate.SunNetSslPackageUnavailable
org.openrewrite.java.migrate.RemovedRMIConnectorServerCredentialTypesConstant
Checklist