-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Some bulk refactorings #282
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
Conversation
|
Rebased from master due to conflicts. |
|
Thanks for the pull request. :) I already cherry-picked a0aed6c which fixes some mistakes. I support merging the rest of the commits, although I'm not sure how much a0aed6c or a032ed6 add. With 0a78058 there is a small change that somebody calls the methods from dynamic groovy, but of course it is important to remove unused stuff. I'm thankful for opinions of other commiters on this. |
|
This one particular |
|
For commit a032ed6 (avoid synthetic accessors by making private fields/methods package-private), I think removing The other commits look good to me. |
|
I also thought about the widening of scope, that may be unintended, but if there's a synthetic accessor method generated, it actually is made available inside the package anyway? Scope-wise there's not much of a difference between a package-private field and a package-private getter, or is there one? |
To my knowledge the synthetic accessors are inserted by the Java compiler so that top-level and inner classes can access private members of each other. From a coding perspective it is not really feasible for another class in the package to use these compiler generated accessors (i.e., they wont show up in IDE code completion). By widening the scope of the members of the enclosing class encapsulation is being broken in order to avoid having a few synthetic accessors; the only benefit might be slight performance increase and that is even very questionable. But many people work on the codebase and encapsulation is more important in my opinion in this context. If someone working in the code see they can access the member they may think it was designed to be accessed by classes in the package when it actually was not.
No I don't believe so. In my original comment I was referring to synthetic accessors in general and not just those generated for methods. I think again it comes back to encapsulation and breaking it just to avoid the synthetic accessors is not a good thing. |
|
Good point about IDEs respecting the synthetic flag, thanks! So I'll revert all the scoping changes in non-inner classes. For private inner classes the scope should not matter that much, since they as a whole are not accessible to any other classes, therefore I leave my changes there. |
|
Rebased from trunk due to conflicts. The only cases left where I changed from private to package-private is for private inner classes now. |
|
Because many of the commits touch the same files it is difficult to review just the changes for the synthetic accessors/package-private. I think for bulk changes like this, even if minor, separate PR's would be easier to review and manage. |
|
Yes I already realized this was a bad idea. I would've love to just fixup the initial scope changing commit, but could not do so without major effort because it conflicts with the other commit adding final here and there, that has been done in the meantime :-/ |
|
Another problem with doing so many changes is that there are a lot of merge conflicts when I try to merge the changes into the 2_4_X branch, but without merging it's highly likely that there will be conflicts when backporting bugfixes. :( |
|
If you want I can go through again and restructure the changes. How do you like it? Individual PRs for each of the commits (except the fixup)? Should those individual PRs only contain one commit each, or do you like it to be split up by some metric? |
|
No further thinking about it I'm not sure if multiple pull request will really help in this case. I guess the pull request would have massive merge conflicts with each other. I think 69ade9e it the most valuable commit, because removing code dead code is good for readability and maintainability. I do not know if there is an easy way to untangle it from the rest? c3ad829 is also nice. Of course the other commit also have value. |
|
I think that bulk refactorings like these are best done one at a time (serially) with each as it's own PR with a single commit focused on the one change and agree that the unused code commit would be a good one to start with. For me I'd wait for it to be merged before starting work on the next PR if lots of the same files are to be touched, and work on them in order of most likely to least likely to be merged. I think that would avoid the headaches of dealing with merge conflicts. |
|
@oreissig I rebased the remove unused code commit. Thanks! |
| this(uri.toURL()); | ||
| } | ||
|
|
||
| public GroovyCodeSource(URL url) throws IOException { |
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 only just spotted this now. While "unused" in the sense that this method didn't throw this exception anymore (I presume it did in the past), removing the exception breaks contract/source code compatibility. :-( I know it is a result of how checked exceptions are handled on the JVM but we should have not done this in a point release - all good to know in hindsight. Anyway, it isn't clear that reverting after a year is going to help things so I'm thinking of just documenting for now with a Jira issue. Apologies if this has already been raised elsewhere.
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.
d'oh, I totally forgot about that :(
| final Set<IvyGrabRecord> grabRecordsForCurrDependencies = new LinkedHashSet<IvyGrabRecord>() | ||
| // we keep the settings so that addResolver can add to the resolver chain | ||
| IvySettings settings | ||
| final IvySettings settings |
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.
not sure those finals are ok, it means there will be no getter for these anymore. So I would like to hear from for example Paul that these are not supposed to have getter
| private void setSize(int size) { | ||
| @Deprecated | ||
| void setSize(int size) { | ||
| throw new UnsupportedOperationException("size must not be changed"); |
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.
why is it deprecated again?
| * convenience factory method for the most usual case. | ||
| */ | ||
| public static ProxyMetaClass getInstance(Class theClass) throws IntrospectionException { | ||
| public static ProxyMetaClass getInstance(Class theClass) { |
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.
removal of checked exception in public method
| /** | ||
| * @param adaptee the MetaClass to decorate with interceptability | ||
| */ | ||
| public ProxyMetaClass(MetaClassRegistry registry, Class theClass, MetaClass adaptee) throws IntrospectionException { |
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.
removal of checked exception in public method
| } | ||
|
|
||
| public static List<DgmMethodRecord> loadDgmInfo() throws IOException, ClassNotFoundException { | ||
| public static List<DgmMethodRecord> loadDgmInfo() throws IOException { |
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.
removal of checked exception from public api
| public class DgmConverter implements Opcodes { | ||
|
|
||
| public static void main(String[] args) throws IOException, ClassNotFoundException { | ||
| public static void main(String[] args) throws IOException { |
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.
even though this is not likely to cause a problem, still removal of checked exception on public method
| * Flush both output streams. | ||
| */ | ||
| public void flush() throws IOException { | ||
| public void flush() { |
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.
removal of checked exception on public method
| return 0; | ||
| } | ||
|
|
||
| private static int normalizeIndex(Object array, int i) { |
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.
normalizeIndex is used via MethodHandle in line 39. you cannot remove these
I went through the codebase of the root project and did the following refactorings:
None of this should change the behaviour in any way.