-
Notifications
You must be signed in to change notification settings - Fork 101
Remove finalizer from classes in util.zip #233
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
Remove finalizer from classes in util.zip #233
Conversation
Thanks a lot for this recipe @satvika-eda ! I'm adding a link here for context: https://bugs.openjdk.org/browse/JDK-8212129 |
I've gone ahead and added some tests to show some of the potential issues I saw with the current implementation; such as also matching finalize methods called on other classes, and removing the select, which could change side effects. Would you want to work through those issues yourself? High over I'd say the recipe is not following the typical pattern I'd expect of recipes; right now you're visiting a class declaration, and through that looking through the body, and from there methods and statements. That's rather narrow in terms of what it will match. You're also matching classes and methods based on their name, rather than the types that we set on tree elements, and the matchers we provide. I'd instead roughly expect a pattern where you first use a Precondition argument to check that any file visited extends Deflater/Inflater/ZipFile, and then as a second argument to Precondition add a visitor that overrides visitMethodInvocation, applies a MethodMatcher for I hope all of that is somewhat clear; we really appreciate you providing the initial implementation here, and hope you'll consider making these changes if you feel comfortable doing so. |
Thank you for your valuable inputs. I've worked on fixing the recipe as per your comments. Please review the PR and provide your inputs. I also made sure all the test cases passed. For "removeCallsToSelfFinalize" test, as finalize() would be called from Object class, before and after would be same as that is not a self finalize as per the recipe. |
Support case of empty select by looking at surrounding class declaration Use method matcher instead of String comparison to find finalize calls Use TypeUtils instead of String comparison to find extending classes
I've made quite some changes in c6613d1 to have the recipe better fit in with our expected use of OpenRewrite, making use of the type system for comparisons where we can. We now also cover this case, by looking at the surrounding class when finalize is called without a selector Hope you agree with the changes, and thank you for your contribution! |
What's changed?
finalize method has been removed from the ZipFile, Deflater and Inflalter of the util package for which the needed automation has been done as part of the recipe created
What's your motivation?
To automate JDK migration to a greater extent
Checklist
./gradlew licenseFormat