-
-
Notifications
You must be signed in to change notification settings - Fork 43
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
Private methods handled as virtual for inherting classes #36
Comments
@meszibalu Thank you for reporting this. It may take a while for me to look into this but just adding a note to mention I saw this. I am not 100% sure I understand problem from description, but I assume reproduction explains it. |
Hmmh. I don't think I agree here -- I don't see why both It is possible I am missing a use case here so would appreciate help. |
Because private methods do not override each other. Let me give you another example: public class A {
private void a() {}
private void x() {}
}
public class B extends A {
private void b() {}
private void x() {}
} If I resolve |
But there is no real way to call masked base class variant. Except perhaps reflection does allow that. So I guess my question is really: what is the use case for this? The reason for my hesitation is that up until this point, uniqueness of signatures (name + arguments + return type) is guaranteed, and conceptually adding both private methods would complicate this part. |
Yes, you are right, reflection allows that, because they are not virtual. For virtual methods, nobody can call the super method. A possible use case for this: I understand your concern, it is quite tricky to handle, and there is a workaround for that if we resolv the members of the base class, so this argument is a little bit theoretical :). This issue also exists for private fields. If you have two private fields with the same name in an inheritance hierarchy, |
I am using classmate-1.3.3 and I faced with an issue when using MemberResolver. The problem is that if a class and its child class have exactly the same private methods then I cannot access to super class' private method. This behavior is fine when these methods are at least package-private, but private methods do not override each other.
For demonstrating the issue I have attached a simple unit test. In
testPrivate()
testmembers.getMemberMethods()
should return two functions in my opinion.InheritanceTest.txt
Best regards,
Balazs
The text was updated successfully, but these errors were encountered: